Skip to content
vispax edited this page Jan 2, 2013 · 2 revisions

Create a file with the name of your group under src/main/webapp/group, if the folder doesn't exist create it. The file must contain the data specification of your group, see the reference.

Create a new resource (as explained here) implementing DatasetResource. Here is an example on how to implement the methods:

  • PUT

      public void uploadData(Representation rep) { 
      	//the client must send a csv, arff, or json in the HTTP body, you must support at least csv  
      	//you can read the stream manually: rep.getStream()  
      	//or use the Instances object 
      	InstancesRepresentation ir = new InstancesRepresentation(rep); 
      	Instances instances = ir.getInstances(); 
      	//you should validate the input, eventually fetching the specifications you declared at the beginning 
      	ClientResource cr = new ClientResource("/group/\<your-group\>"); 
      	cr.setChallengeResponse(getChallengeResponse()); 
      	DataSpecification spec = cr.get(DataSpecification.class); 
      	if (spec.matchingSpecification(instances)) 
      	//do your handling
      	else throw new ResourceException(Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY);
      }
    
  • DELETE

      public void deleteData() {
          //simply delete the stored data
      }
    

URI

you should attach the class with the following URI: /group/<your-group>/data

Test

You can test it as a normal resource, but you should place the xml specification in the group directory under src/test/resources

Tips

The DatasetResource interface is intended to perform CRUD operations on datasets. If you need to perform any analysis on data, especially if it can be performed with different parameters, consider using the built-in functions developing a plugin. See reference.

Clone this wiki locally