@Override
	public Response handle(JsonElement data) {
		Response res;
		
		Fingerprint fprint = GsonFactory.getGsonInstance().fromJson(data, Fingerprint.class);
		if (fprint.getLocation() != null && ((Location)fprint.getLocation()).getId() != null && ((Location)fprint.getLocation()).getId().intValue() != -1) {
			Location l = HomeFactory.getLocationHome().getLocation(((Location)fprint.getLocation()).getId(), null);
			fprint = new Fingerprint(l,(Measurement)fprint.getMeasurement());
		}
		fprint = fingerprintHome.add(fprint);
		
		if(fprint == null) {
			res = new Response(Status.failed, "could not add to database", null);
			Log.getLogger().fine("fingerpint could not be added to the database");
		} else {
			res = new Response(Status.ok, null, fprint);
			Log.getLogger().finer("fingerprint set: " + fprint);
			
			
			Location loc = (Location)fprint.getLocation();
			int count = fingerprintHome.getCount(loc);
			
			if (count < INSTANT_TRAIN_THREASHOLD) {
				Log.getLogger().fine("Training model (fp count for loc " + loc.getSymbolicID() + ": " + count);
				Thread trainer = new Thread(new Runnable() {				
					@Override
					public void run() {
						SVMSupport.train();					
					}
				});
				trainer.start();			
			}
			
		}
		
				
		
		return res;
	}