예제 #1
0
  @GET
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  public Collection<Function> getAllFunctionsForDevice() throws SQLException {
    DeviceDAO daoDevice = new DeviceDAO();
    Device currentDevice = new Device();
    currentDevice.setId(device);
    Device curDev = daoDevice.findByID(currentDevice);
    Collection<Function> functions = curDev.getFunctions();

    return functions;
  }
예제 #2
0
  @Path("new/{name: .* }")
  @GET
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  public Function setFunction(@PathParam("name") String name) throws SQLException {

    DeviceFunctionDAO daoDeviceFunction = new DeviceFunctionDAO();
    Function newFunction = new Function();
    newFunction.setName(name);

    DeviceDAO daoDevice = new DeviceDAO();
    Device currentDevice = new Device();
    currentDevice.setId(device);
    Device curDev = daoDevice.findByID(currentDevice);
    curDev.getFunctions().add(newFunction);
    newFunction.setDevice(currentDevice);
    daoDeviceFunction.create(curDev, newFunction);

    return newFunction;
  }