org.apache.stanbol.entityhub.jersey.utils
Class LDPathHelper

java.lang.Object
  extended by org.apache.stanbol.entityhub.jersey.utils.LDPathHelper

public class LDPathHelper
extends Object


Field Summary
static at.newmedialab.ldpath.model.fields.FieldMapping<Double,Object> RESULT_SCORE_MAPPING
          LDPath FieldMapping for the RdfResourceEnum.resultScore property used for the score of query results
 
Constructor Summary
LDPathHelper()
           
 
Method Summary
static Map<String,String> getLDPathParseExceptionMessage(at.newmedialab.ldpath.exception.LDPathParseException e)
          Utility that gets the messages of the parsing error.
static javax.ws.rs.core.Response handleLDPathRequest(org.apache.stanbol.commons.web.base.resource.BaseStanbolResource resource, at.newmedialab.ldpath.api.backend.RDFBackend<Object> backend, String ldpath, Set<String> contexts, javax.ws.rs.core.HttpHeaders headers, javax.servlet.ServletContext servletContext)
          Processes LDPath requests as supported by the SiteManagerRootResource, ReferencedSiteRootResource, EntityhubRootResource.
static at.newmedialab.ldpath.model.programs.Program<Object> prepareQueryLDPathProgram(String ldpathProgram, Set<String> selectedFields, org.apache.stanbol.entityhub.ldpath.backend.AbstractBackend backend, org.apache.stanbol.entityhub.ldpath.EntityhubLDPath ldPath)
           
static Collection<org.apache.stanbol.entityhub.servicesapi.model.Representation> transformQueryResults(Iterator<org.apache.stanbol.entityhub.servicesapi.model.Representation> resultIt, at.newmedialab.ldpath.model.programs.Program<Object> program, Set<String> selectedFields, org.apache.stanbol.entityhub.ldpath.EntityhubLDPath ldPath, org.apache.stanbol.entityhub.ldpath.backend.AbstractBackend backend, org.apache.stanbol.entityhub.servicesapi.model.ValueFactory vf)
          Transform the results of a query
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESULT_SCORE_MAPPING

public static final at.newmedialab.ldpath.model.fields.FieldMapping<Double,Object> RESULT_SCORE_MAPPING
LDPath FieldMapping for the RdfResourceEnum.resultScore property used for the score of query results

Constructor Detail

LDPathHelper

public LDPathHelper()
Method Detail

getLDPathParseExceptionMessage

public static Map<String,String> getLDPathParseExceptionMessage(at.newmedialab.ldpath.exception.LDPathParseException e)
Utility that gets the messages of the parsing error. The message about the problem is contained in some parent Exception. Therefore this follows Throwable.getCause()s. The toString method of the returned map will print the "exception: message" in the correct order.

Parameters:
e - the exception
Returns:
the info useful to replay in BAD_REQUEST responses

handleLDPathRequest

public static javax.ws.rs.core.Response handleLDPathRequest(org.apache.stanbol.commons.web.base.resource.BaseStanbolResource resource,
                                                            at.newmedialab.ldpath.api.backend.RDFBackend<Object> backend,
                                                            String ldpath,
                                                            Set<String> contexts,
                                                            javax.ws.rs.core.HttpHeaders headers,
                                                            javax.servlet.ServletContext servletContext)
Processes LDPath requests as supported by the SiteManagerRootResource, ReferencedSiteRootResource, EntityhubRootResource.

Parameters:
resource - The resource used as context when sending RESTful Service API Viewable as response entity.
backend - The RDFBackend implementation
ldpath - the parsed LDPath program
contexts - the Entities to execute the LDPath program
headers - the parsed HTTP headers (used to determine the accepted content type for the response
servletContext - The Servlet context needed for CORS support
Returns:
the Response Response.Status.BAD_REQUEST or Response.Status.OK.

transformQueryResults

public static Collection<org.apache.stanbol.entityhub.servicesapi.model.Representation> transformQueryResults(Iterator<org.apache.stanbol.entityhub.servicesapi.model.Representation> resultIt,
                                                                                                              at.newmedialab.ldpath.model.programs.Program<Object> program,
                                                                                                              Set<String> selectedFields,
                                                                                                              org.apache.stanbol.entityhub.ldpath.EntityhubLDPath ldPath,
                                                                                                              org.apache.stanbol.entityhub.ldpath.backend.AbstractBackend backend,
                                                                                                              org.apache.stanbol.entityhub.servicesapi.model.ValueFactory vf)
Transform the results of a query

Parameters:
resultIt - The Iterator over the results
program - the LDPath Program to execute on the results
selectedFields - additional selected fields of the query
ldPath - the Entityhub LDPath
backend - the AbstractBackend mainly used to add representations of the query to the local cache
vf - the ValueFactory used create References for the String ids of the Representation in the query results
Returns:
A collection with the transformed Representations in the processed order.

prepareQueryLDPathProgram

public static at.newmedialab.ldpath.model.programs.Program<Object> prepareQueryLDPathProgram(String ldpathProgram,
                                                                                             Set<String> selectedFields,
                                                                                             org.apache.stanbol.entityhub.ldpath.backend.AbstractBackend backend,
                                                                                             org.apache.stanbol.entityhub.ldpath.EntityhubLDPath ldPath)
                                                                                      throws at.newmedialab.ldpath.exception.LDPathParseException
Parameters:
ldpathProgram - the LDPath program as string
selectedFields - the selected fields of the query
backend - the RDFBackend (only needed for logging)
ldPath - the LDPath used to parse the program.
Returns:
the pre-processed and validated program
Throws:
at.newmedialab.ldpath.exception.LDPathParseException - if the parsed LDPath program string is not valid
IllegalStateException - if the fields selected by the LDPath program conflict with the fields selected by the query.


Copyright © 2010-2013 The Apache Software Foundation. All Rights Reserved.