code: public static Map<String, QueryParameter> getOrderedParametersMap(Query query, Map<String, QueryParameter> allParameters) {    	
          Set<String> paramNames = new LinkedHashSet<String>(Arrays.asList(query.getParameterNames()));
          for (QueryParameter p : allParameters.values()) {   
          	if (p.getDependentParameterNames().size() > 0) {
          		paramNames.remove(p.getName());
          	}
          	paramNames.addAll(p.getDependentParameterNames());
          	if (p.getDependentParameterNames().size() > 0) {
          		paramNames.add(p.getName());
          	}
          }        
          LinkedHashMap<String, QueryParameter> params = new LinkedHashMap<String, QueryParameter>();
          for (String name :paramNames) {        	            
              QueryParameter qp = allParameters.get(name);            
              params.put(name, qp);            
          }        
          return params;
      }
docs: Get ordered parameters map (dependent parameters are after their dependents)  where the key is the parameter name and
  the value is the parameter
  The result will contain also the hidden parameters and all parameters used just inside other parameters.
  
  @param query         query object
  @param allParameters parameters map
  @return ordered parameters map