@Test public void testGetDescription() throws Exception { Name<?> id = NamingScheme.getDefault().name("Test"); Query query = QueryBuilder. newInstance(). withParameter("param1", "value1"). withParameter("param1", "value2"). withParameter("param2", "value1"). build(); DataSet data=QuerySupport.getDescription(id, query); assertThat((Object)data.name(),sameInstance((Object)id)); DataSetHelper dHelper = DataSetUtils.newHelper(data); IndividualHelper qInd = dHelper.localIndividual(QuerySupport.queryId()); assertThat(qInd.types(),contains(QuerySupport.QUERY_TYPE)); IndividualHelper pInd = dHelper.localIndividual(QuerySupport.parameterId("param1")); assertThat(pInd.types(),contains(QuerySupport.PARAMETER_TYPE)); }
static DataSet getDescription(Name<?> id, Query query) throws InvalidQueryException { DataSet dataset = DataSets.createDataSet(id); if(query.hasParameter(QueryableResourceHandler.FAILURE)) { Parameter failure=query.getParameter(QueryableResourceHandler.FAILURE); try { if(failure.rawValueAs(Boolean.class)) { throw new InvalidQueryException("Failure requested", query); } } catch (ObjectTransformationException e) { throw new InvalidQueryException("Could not understand: '"+failure.rawValue()+"' is not a valid boolean value for parameter '"+QueryableResourceHandler.FAILURE+"'",e,query); } } LocalIndividual qIndividual =dataset.individual(queryId(), LocalIndividual.class); ExternalIndividual qtIndividual=dataset.individual(QuerySupport.QUERY_TYPE, ExternalIndividual.class); ExternalIndividual ptIndividual=dataset.individual(QuerySupport.PARAMETER_TYPE, ExternalIndividual.class); qIndividual.addValue(QuerySupport.TYPE, qtIndividual); for(String parameterName:query.parameterNames()) { LocalIndividual pIndividual= dataset. individual( parameterId(parameterName), LocalIndividual.class); qIndividual.addValue(QuerySupport.HAS_PARAMETER, pIndividual); pIndividual.addValue(QuerySupport.TYPE, ptIndividual); pIndividual.addValue(QuerySupport.HAS_NAME, Literals.of(parameterName)); for(String rawValue:query.getParameter(parameterName).rawValues()) { pIndividual.addValue(QuerySupport.HAS_VALUE, Literals.of(rawValue)); } } return dataset; }
QuerySupport { static DataSet getDescription(Name<?> id, Query query) throws InvalidQueryException { DataSet dataset = DataSets.createDataSet(id); if(query.hasParameter(QueryableResourceHandler.FAILURE)) { Parameter failure=query.getParameter(QueryableResourceHandler.FAILURE); try { if(failure.rawValueAs(Boolean.class)) { throw new InvalidQueryException("Failure requested", query); } } catch (ObjectTransformationException e) { throw new InvalidQueryException("Could not understand: '"+failure.rawValue()+"' is not a valid boolean value for parameter '"+QueryableResourceHandler.FAILURE+"'",e,query); } } LocalIndividual qIndividual =dataset.individual(queryId(), LocalIndividual.class); ExternalIndividual qtIndividual=dataset.individual(QuerySupport.QUERY_TYPE, ExternalIndividual.class); ExternalIndividual ptIndividual=dataset.individual(QuerySupport.PARAMETER_TYPE, ExternalIndividual.class); qIndividual.addValue(QuerySupport.TYPE, qtIndividual); for(String parameterName:query.parameterNames()) { LocalIndividual pIndividual= dataset. individual( parameterId(parameterName), LocalIndividual.class); qIndividual.addValue(QuerySupport.HAS_PARAMETER, pIndividual); pIndividual.addValue(QuerySupport.TYPE, ptIndividual); pIndividual.addValue(QuerySupport.HAS_NAME, Literals.of(parameterName)); for(String rawValue:query.getParameter(parameterName).rawValues()) { pIndividual.addValue(QuerySupport.HAS_VALUE, Literals.of(rawValue)); } } return dataset; } }
QuerySupport { static DataSet getDescription(Name<?> id, Query query) throws InvalidQueryException { DataSet dataset = DataSets.createDataSet(id); if(query.hasParameter(QueryableResourceHandler.FAILURE)) { Parameter failure=query.getParameter(QueryableResourceHandler.FAILURE); try { if(failure.rawValueAs(Boolean.class)) { throw new InvalidQueryException("Failure requested", query); } } catch (ObjectTransformationException e) { throw new InvalidQueryException("Could not understand: '"+failure.rawValue()+"' is not a valid boolean value for parameter '"+QueryableResourceHandler.FAILURE+"'",e,query); } } LocalIndividual qIndividual =dataset.individual(queryId(), LocalIndividual.class); ExternalIndividual qtIndividual=dataset.individual(QuerySupport.QUERY_TYPE, ExternalIndividual.class); ExternalIndividual ptIndividual=dataset.individual(QuerySupport.PARAMETER_TYPE, ExternalIndividual.class); qIndividual.addValue(QuerySupport.TYPE, qtIndividual); for(String parameterName:query.parameterNames()) { LocalIndividual pIndividual= dataset. individual( parameterId(parameterName), LocalIndividual.class); qIndividual.addValue(QuerySupport.HAS_PARAMETER, pIndividual); pIndividual.addValue(QuerySupport.TYPE, ptIndividual); pIndividual.addValue(QuerySupport.HAS_NAME, Literals.of(parameterName)); for(String rawValue:query.getParameter(parameterName).rawValues()) { pIndividual.addValue(QuerySupport.HAS_VALUE, Literals.of(rawValue)); } } return dataset; } private  QuerySupport(); }
QuerySupport { static DataSet getDescription(Name<?> id, Query query) throws InvalidQueryException { DataSet dataset = DataSets.createDataSet(id); if(query.hasParameter(QueryableResourceHandler.FAILURE)) { Parameter failure=query.getParameter(QueryableResourceHandler.FAILURE); try { if(failure.rawValueAs(Boolean.class)) { throw new InvalidQueryException("Failure requested", query); } } catch (ObjectTransformationException e) { throw new InvalidQueryException("Could not understand: '"+failure.rawValue()+"' is not a valid boolean value for parameter '"+QueryableResourceHandler.FAILURE+"'",e,query); } } LocalIndividual qIndividual =dataset.individual(queryId(), LocalIndividual.class); ExternalIndividual qtIndividual=dataset.individual(QuerySupport.QUERY_TYPE, ExternalIndividual.class); ExternalIndividual ptIndividual=dataset.individual(QuerySupport.PARAMETER_TYPE, ExternalIndividual.class); qIndividual.addValue(QuerySupport.TYPE, qtIndividual); for(String parameterName:query.parameterNames()) { LocalIndividual pIndividual= dataset. individual( parameterId(parameterName), LocalIndividual.class); qIndividual.addValue(QuerySupport.HAS_PARAMETER, pIndividual); pIndividual.addValue(QuerySupport.TYPE, ptIndividual); pIndividual.addValue(QuerySupport.HAS_NAME, Literals.of(parameterName)); for(String rawValue:query.getParameter(parameterName).rawValues()) { pIndividual.addValue(QuerySupport.HAS_VALUE, Literals.of(rawValue)); } } return dataset; } private  QuerySupport();  }
QuerySupport { static DataSet getDescription(Name<?> id, Query query) throws InvalidQueryException { DataSet dataset = DataSets.createDataSet(id); if(query.hasParameter(QueryableResourceHandler.FAILURE)) { Parameter failure=query.getParameter(QueryableResourceHandler.FAILURE); try { if(failure.rawValueAs(Boolean.class)) { throw new InvalidQueryException("Failure requested", query); } } catch (ObjectTransformationException e) { throw new InvalidQueryException("Could not understand: '"+failure.rawValue()+"' is not a valid boolean value for parameter '"+QueryableResourceHandler.FAILURE+"'",e,query); } } LocalIndividual qIndividual =dataset.individual(queryId(), LocalIndividual.class); ExternalIndividual qtIndividual=dataset.individual(QuerySupport.QUERY_TYPE, ExternalIndividual.class); ExternalIndividual ptIndividual=dataset.individual(QuerySupport.PARAMETER_TYPE, ExternalIndividual.class); qIndividual.addValue(QuerySupport.TYPE, qtIndividual); for(String parameterName:query.parameterNames()) { LocalIndividual pIndividual= dataset. individual( parameterId(parameterName), LocalIndividual.class); qIndividual.addValue(QuerySupport.HAS_PARAMETER, pIndividual); pIndividual.addValue(QuerySupport.TYPE, ptIndividual); pIndividual.addValue(QuerySupport.HAS_NAME, Literals.of(parameterName)); for(String rawValue:query.getParameter(parameterName).rawValues()) { pIndividual.addValue(QuerySupport.HAS_VALUE, Literals.of(rawValue)); } } return dataset; } private  QuerySupport();  static final String NAMESPACE; static final URI QUERY_TYPE; static final URI PARAMETER_TYPE; static final URI HAS_PARAMETER; static final URI HAS_VALUE; static final URI HAS_NAME; }