code: @Override
      public QueryDefinition registerQuery(QueryDefinition queryDefinition) {
          QueryDefinition result = null;
          if (config.isRest()) {
  
              Map<String, Object> valuesMap = new HashMap<String, Object>();
              valuesMap.put(QUERY_NAME, queryDefinition.getName());
  
              result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + CREATE_QUERY_DEF_POST_URI, valuesMap), queryDefinition, QueryDefinition.class);
  
          } else {
              CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "registerQuery", serialize(queryDefinition), marshaller.getFormat().getType(), new Object[]{queryDefinition.getName()})));
              ServiceResponse<QueryDefinition> response = (ServiceResponse<QueryDefinition>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
  
              throwExceptionOnFailure(response);
              if (shouldReturnWithNullResponse(response)) {
                  return null;
              }
              result = response.getResult();
          }
  
          return result;
      }
docs: QueryDataService related