code: public static void deleteNode(DbConn cnx, int id)
      {
          int countRunning = cnx.runSelectSingle("ji_select_count_by_node", Integer.class, id);
          if (countRunning > 0)
          {
              cnx.setRollbackOnly();
              throw new JqmAdminApiUserException(
                      "cannot delete a node with running instances. Disable it, wait for the end of all running instances, then retry.");
          }
  
          try
          {
              Node n = Node.select_single(cnx, "node_select_by_id", id);
              Calendar limit = Calendar.getInstance();
              limit.add(Calendar.MINUTE, -10);
              if (n.getLastSeenAlive() != null && n.getLastSeenAlive().after(limit))
              {
                  cnx.setRollbackOnly();
                  throw new JqmAdminApiUserException(
                          "Can only remove a node either properly shut down or that has crashed more than 10 minutes ago.");
              }
          }
          catch (NoResultException e)
          {
              throw new JqmAdminApiUserException("no item with ID " + id);
          }
  
          cnx.runUpdate("dp_delete_for_node", id);
          QueryResult qr = cnx.runUpdate("node_delete_by_id", id);
          if (qr.nbUpdated != 1)
          {
              cnx.setRollbackOnly();
              throw new JqmAdminApiUserException("no item with ID " + id);
          }
      }
docs: /////////////////////////////////////////////////////////////////////////