This page last changed on Nov 04, 2008 by amitku.

Data Structure

Both Workset and Project are defined as a Hashtable with parameters as keys

Workset

Data Structure for creating new workset and returned from getWorkset call

keys value required Input present in output
id string no yes
dateCreated date no yes
lastDateAccessed date no yes
name string yes yes
trainingList string comma delimited yes yes
workList string comma delimited yes yes
feature Lemma or Spelling yes yes

An example

        worksetHt.put("name","workset name");
        worksetHt.put("trainingList","ncf-0101-2,ncf-0101");
        worksetHt.put("workList","ncf-0101-2,ncf-0101-1,ncf-0101");
        worksetHt.put("feature","Lemma");

WorksetInfo

This is the hashtable structure returned by getWorksets

keys value required Input present in output
id long no yes
name string yes yes
dateCreated date no yes
lastDateAccessed date no yes
numTestList int no yes
numTrainingList int no yes

Project

Data Structure to create new project and returned from getProjects call

keys value required input present in output
name string yes yes
comments string yes yes
id long no yes
numWorksets int no yes

The getProjects call returns two additional parameter numWorksets and id

        Hashtable ht = new Hashtable();
        ht.put("name","Project by XMLRPC");
        ht.put("comments","Project Description -XMLRPC ");

XML RPC Methods

Server URL: /get/xmlrpc

See incomplete sample code: Java Client.java Python monk-xmlrpc.py

-All the functions start with monk1 as the prefix

monk1.login

This function returns a token string. The token string is used by rest of the calls.

params value required position
user user name yes 1
password password for the user yes 2

Returns a Token String

Example usage:

Object[] parameters = new Object[]{"admin","password"};
String token =(String)client.execute("monk1.login", parameters);
        

monk1.logout

params value required position
token string value yes 1

Returns: boolean -true or false

Example usage:

Object[] parameters = new Object{"token"}
Boolean result = (Boolean) client.execute("monk1.logout",parameters);

monk1.getProjects

params value required position
token string yes 1

Returns: An Array of Project Objects

Example usage:

Object[] parameters = new Object{$token}	
Object[] projectList=(Object[])client.execute("monk1.getProjects",parameters);
	
   for(Object obj: projectList){
        HashMap<String,Object> hm = (HashMap<String,Object>)obj;
        	for(String key: hm.keySet()){
        	System.out.print(key+":"+hm.get(key)+"{"+hm.get(key)+"}");
        	}
        }

monk1.getWorkset

params value required position
token string yes 1
worksetId integer yes 2

Returns a Workset Object

Example usage:

Object[] parameters = new Object{$token,$worksetId}	
Object obj=(Object[])client.execute("monk1.getWorkset",parameters);
	
        HashMap<String,Object> hm = (HashMap<String,Object>)obj;
        	for(String key: hm.keySet()){
        	System.out.print(key+":"+hm.get(key)+"{"+hm.get(key)+"}");
        	}
   

monk1.getWorksets

params value required position
token string yes 1
projectId integer yes 2

Returns an Array of WorksetInfo Objects

Example usage:

Object[] parameters = new Object{$token,$projectId}	
Object[] worksetList=(Object[])client.execute("monk1.getWorksets",parameters);
	
   for(Object obj: worksetList){
        HashMap<String,Object> hm = (HashMap<String,Object>)obj;
        	for(String key: hm.keySet()){
        	System.out.print(key+":"+hm.get(key)+"{"+hm.get(key)+"}");
        	}
        }

monk1.addProject

params value required position
token string yes 1
project hashtable Hashtable Project yes 2

@Returns a HashMap with "success" key and if the value is true -it also returns the projectId
with id as the parameter

Example usage:

 Object[] projectParams = new Object[2];
        Hashtable ht = new Hashtable();
        ht.put("name","Project by XMLRPC");
        ht.put("description","Project Description -XMLRPC ");
        projectParams[0]=token;
        projectParams[1]=ht;        	
        HashMap<String,Object> hm = (HashMap<String,Object>)client.execute("monk1.addProject",projectParams);

monk1.addWorkset

params value required position
token string yes 1
projectId integer yes 2
workset hashtable Hashtable Workset yes 3

@Returns a HashMap with "success" key and if the value is true -it also returns the worksetId
with id as the parameter
Example usage:

        /*fillup a hashtable with the workset information*/
        Hashtable<String,Object> worksetHt = new Hashtable<String,Object>();
        worksetHt.put("name","workset name");
        worksetHt.put("trainingList","ncf-0101-2,ncf-0101");
        worksetHt.put("workList","ncf-0101-2,ncf-0101-1,ncf-0101");
        worksetHt.put("feature","Lemma");
 
        /*create the parameters for the call*/
        Object[] worksetParams = new Object[3];
        worksetParams[0] = token; // token
        worksetParams[1]= 91; // this is the projectId you want to add the workset to
        worksetParams[2]= worksetHt; // workset hashtable
        
        HashMap<String,Object> htob=( HashMap<String,Object>)client.execute("monk1.addWorkset",worksetParams);
      
       boolean success = htob.get("success");  
       int worksetId = htop.get("id");

Client.java (text/plain)
monk-xmlrpc.py (text/x-python-script)
Document generated by Confluence on Apr 19, 2009 15:04