Class ContextImpl
- java.lang.Object
-
- org.apache.solr.handler.dataimport.Context
-
- org.apache.solr.handler.dataimport.ContextImpl
-
public class ContextImpl extends Context
An implementation for the Context
This API is experimental and subject to change- Since:
- solr 1.3
-
-
Field Summary
Fields Modifier and Type Field Description protected EntityProcessorWrapper
epw
-
Fields inherited from class org.apache.solr.handler.dataimport.Context
DELTA_DUMP, FIND_DELTA, FULL_DUMP, SCOPE_DOC, SCOPE_ENTITY, SCOPE_GLOBAL, SCOPE_SOLR_CORE
-
-
Constructor Summary
Constructors Constructor Description ContextImpl(EntityProcessorWrapper epw, VariableResolver resolver, DataSource ds, String currProcess, Map<String,Object> global, ContextImpl parentContext, DocBuilder docBuilder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
currentProcess()
Returns the current process FULL_DUMP, DELTA_DUMP, FIND_DELTAvoid
deleteDoc(String id)
delete a document by idvoid
deleteDocByQuery(String query)
delete documents by queryList<Map<String,String>>
getAllEntityFields()
Returns all the fields put into an entity.DataSource
getDataSource()
Gets the datasource instance defined for this entity.DataSource
getDataSource(String name)
Gets a new DataSource instance with a name.String
getEntityAttribute(String name)
Get the value of any attribute put into this entityEntityProcessor
getEntityProcessor()
Returns the instance of EntityProcessor used for this entityException
getLastException()
Context
getParentContext()
Get the context instance for the parent entity.Map<String,Object>
getRequestParameters()
The request parameters passed over HTTP for this command the values in the map are either String(for single valued parameters) or List<String> (for multi-valued parameters)String
getResolvedEntityAttribute(String name)
Get the value of any attribute put into this entity after resolving all variables found in the attribute valueString
getScript()
Returns the text specified in the script tag in the data-config.xmlString
getScriptLanguage()
Returns the language of the script as specified in the script tag in data-config.xmlObject
getSessionAttribute(String name, String scope)
get a value by name in the given scope (entity, document,global)SolrCore
getSolrCore()
Exposing the actual SolrCore to the componentsMap<String,Object>
getStats()
Makes available some basic running statistics such as "docCount", "deletedDocCount", "rowCount", "queryCount" and "skipDocCount"VariableResolver
getVariableResolver()
Returns the VariableResolver used in this entity which can be used to resolve the tokens in ${<namespce.name>}boolean
isRootEntity()
Returns if the current entity is the root entityString
replaceTokens(String template)
Resolve variables in a templateObject
resolve(String var)
Use this directly to resolve variablevoid
setLastException(Exception lastException)
void
setSessionAttribute(String name, Object val, String scope)
Store values in a certain name and scope (entity, document,global)
-
-
-
Field Detail
-
epw
protected EntityProcessorWrapper epw
-
-
Constructor Detail
-
ContextImpl
public ContextImpl(EntityProcessorWrapper epw, VariableResolver resolver, DataSource ds, String currProcess, Map<String,Object> global, ContextImpl parentContext, DocBuilder docBuilder)
-
-
Method Detail
-
getEntityAttribute
public String getEntityAttribute(String name)
Description copied from class:Context
Get the value of any attribute put into this entity- Specified by:
getEntityAttribute
in classContext
- Parameters:
name
- name of the attribute eg: 'name'- Returns:
- value of named attribute in entity
-
getResolvedEntityAttribute
public String getResolvedEntityAttribute(String name)
Description copied from class:Context
Get the value of any attribute put into this entity after resolving all variables found in the attribute value- Specified by:
getResolvedEntityAttribute
in classContext
- Parameters:
name
- name of the attribute- Returns:
- value of the named attribute after resolving all variables
-
getAllEntityFields
public List<Map<String,String>> getAllEntityFields()
Description copied from class:Context
Returns all the fields put into an entity. each item (which is a map ) in the list corresponds to one field. each if the map contains the attribute names and values in a field- Specified by:
getAllEntityFields
in classContext
- Returns:
- all fields in an entity
-
getVariableResolver
public VariableResolver getVariableResolver()
Description copied from class:Context
Returns the VariableResolver used in this entity which can be used to resolve the tokens in ${<namespce.name>}- Specified by:
getVariableResolver
in classContext
- Returns:
- a VariableResolver instance
- See Also:
VariableResolver
-
getDataSource
public DataSource getDataSource()
Description copied from class:Context
Gets the datasource instance defined for this entity. Do not close() this instance. Transformers should use the getDataSource(String name) method.- Specified by:
getDataSource
in classContext
- Returns:
- a new DataSource instance as configured for the current entity
- See Also:
DataSource
,Context.getDataSource(String)
-
getDataSource
public DataSource getDataSource(String name)
Description copied from class:Context
Gets a new DataSource instance with a name. Ensure that you close() this after use because this is created just for this method call.- Specified by:
getDataSource
in classContext
- Parameters:
name
- Name of the dataSource as defined in the dataSource tag- Returns:
- a new DataSource instance
- See Also:
DataSource
-
isRootEntity
public boolean isRootEntity()
Description copied from class:Context
Returns if the current entity is the root entity- Specified by:
isRootEntity
in classContext
- Returns:
- true if current entity is the root entity, false otherwise
-
currentProcess
public String currentProcess()
Description copied from class:Context
Returns the current process FULL_DUMP, DELTA_DUMP, FIND_DELTA- Specified by:
currentProcess
in classContext
- Returns:
- the type of the current running process
-
getRequestParameters
public Map<String,Object> getRequestParameters()
Description copied from class:Context
The request parameters passed over HTTP for this command the values in the map are either String(for single valued parameters) or List<String> (for multi-valued parameters)- Specified by:
getRequestParameters
in classContext
- Returns:
- the request parameters passed in the URL to initiate this process
-
getEntityProcessor
public EntityProcessor getEntityProcessor()
Description copied from class:Context
Returns the instance of EntityProcessor used for this entity- Specified by:
getEntityProcessor
in classContext
- Returns:
- instance of EntityProcessor used for the current entity
- See Also:
EntityProcessor
-
setSessionAttribute
public void setSessionAttribute(String name, Object val, String scope)
Description copied from class:Context
Store values in a certain name and scope (entity, document,global)- Specified by:
setSessionAttribute
in classContext
- Parameters:
name
- the keyval
- the valuescope
- the scope in which the given key, value pair is to be stored
-
getSessionAttribute
public Object getSessionAttribute(String name, String scope)
Description copied from class:Context
get a value by name in the given scope (entity, document,global)- Specified by:
getSessionAttribute
in classContext
- Parameters:
name
- the keyscope
- the scope from which the value is to be retrieved- Returns:
- the object stored in the given scope with the given key
-
getParentContext
public Context getParentContext()
Description copied from class:Context
Get the context instance for the parent entity. works only in the full dump If the current entity is rootmost a null is returned- Specified by:
getParentContext
in classContext
- Returns:
- parent entity's Context
-
getSolrCore
public SolrCore getSolrCore()
Description copied from class:Context
Exposing the actual SolrCore to the components- Specified by:
getSolrCore
in classContext
- Returns:
- the core
-
getStats
public Map<String,Object> getStats()
Description copied from class:Context
Makes available some basic running statistics such as "docCount", "deletedDocCount", "rowCount", "queryCount" and "skipDocCount"
-
getScript
public String getScript()
Description copied from class:Context
Returns the text specified in the script tag in the data-config.xml
-
getScriptLanguage
public String getScriptLanguage()
Description copied from class:Context
Returns the language of the script as specified in the script tag in data-config.xml- Specified by:
getScriptLanguage
in classContext
-
deleteDoc
public void deleteDoc(String id)
Description copied from class:Context
delete a document by id
-
deleteDocByQuery
public void deleteDocByQuery(String query)
Description copied from class:Context
delete documents by query- Specified by:
deleteDocByQuery
in classContext
-
resolve
public Object resolve(String var)
Description copied from class:Context
Use this directly to resolve variable
-
replaceTokens
public String replaceTokens(String template)
Description copied from class:Context
Resolve variables in a template- Specified by:
replaceTokens
in classContext
- Returns:
- The string w/ variables resolved
-
getLastException
public Exception getLastException()
-
setLastException
public void setLastException(Exception lastException)
-
-