|
MONK : XML RPC
This page last changed on Nov 04, 2008 by amitku.
Data StructureBoth Workset and Project are defined as a Hashtable with parameters as keys WorksetData Structure for creating new workset and returned from getWorkset call
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");
WorksetInfoThis is the hashtable structure returned by getWorksets
ProjectData Structure to create new project and returned from getProjects call
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 MethodsServer URL: /get/xmlrpc See incomplete sample code: Java Client.java Python monk-xmlrpc.py -All the functions start with monk1 as the prefix monk1.loginThis function returns a token string. The token string is used by rest of the calls.
Returns a Token String Example usage: Object[] parameters = new Object[]{"admin","password"}; String token =(String)client.execute("monk1.login", parameters); monk1.logout
Returns: boolean -true or false Example usage: Object[] parameters = new Object{"token"} Boolean result = (Boolean) client.execute("monk1.logout",parameters); monk1.getProjects
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
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
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
@Returns a HashMap with "success" key and if the value is true -it also returns the projectId 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
@Returns a HashMap with "success" key and if the value is true -it also returns the worksetId
/*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");
|
| Document generated by Confluence on Apr 19, 2009 15:04 |