コード例 #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;
  }