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 EntityProcessorWrapperepw-
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 StringcurrentProcess()Returns the current process FULL_DUMP, DELTA_DUMP, FIND_DELTAvoiddeleteDoc(String id)delete a document by idvoiddeleteDocByQuery(String query)delete documents by queryList<Map<String,String>>getAllEntityFields()Returns all the fields put into an entity.DataSourcegetDataSource()Gets the datasource instance defined for this entity.DataSourcegetDataSource(String name)Gets a new DataSource instance with a name.StringgetEntityAttribute(String name)Get the value of any attribute put into this entityEntityProcessorgetEntityProcessor()Returns the instance of EntityProcessor used for this entityExceptiongetLastException()ContextgetParentContext()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)StringgetResolvedEntityAttribute(String name)Get the value of any attribute put into this entity after resolving all variables found in the attribute valueStringgetScript()Returns the text specified in the script tag in the data-config.xmlStringgetScriptLanguage()Returns the language of the script as specified in the script tag in data-config.xmlObjectgetSessionAttribute(String name, String scope)get a value by name in the given scope (entity, document,global)SolrCoregetSolrCore()Exposing the actual SolrCore to the componentsMap<String,Object>getStats()Makes available some basic running statistics such as "docCount", "deletedDocCount", "rowCount", "queryCount" and "skipDocCount"VariableResolvergetVariableResolver()Returns the VariableResolver used in this entity which can be used to resolve the tokens in ${<namespce.name>}booleanisRootEntity()Returns if the current entity is the root entityStringreplaceTokens(String template)Resolve variables in a templateObjectresolve(String var)Use this directly to resolve variablevoidsetLastException(Exception lastException)voidsetSessionAttribute(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:ContextGet the value of any attribute put into this entity- Specified by:
getEntityAttributein 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:ContextGet the value of any attribute put into this entity after resolving all variables found in the attribute value- Specified by:
getResolvedEntityAttributein 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:ContextReturns 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:
getAllEntityFieldsin classContext- Returns:
- all fields in an entity
-
getVariableResolver
public VariableResolver getVariableResolver()
Description copied from class:ContextReturns the VariableResolver used in this entity which can be used to resolve the tokens in ${<namespce.name>}- Specified by:
getVariableResolverin classContext- Returns:
- a VariableResolver instance
- See Also:
VariableResolver
-
getDataSource
public DataSource getDataSource()
Description copied from class:ContextGets the datasource instance defined for this entity. Do not close() this instance. Transformers should use the getDataSource(String name) method.- Specified by:
getDataSourcein 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:ContextGets 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:
getDataSourcein 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:ContextReturns if the current entity is the root entity- Specified by:
isRootEntityin classContext- Returns:
- true if current entity is the root entity, false otherwise
-
currentProcess
public String currentProcess()
Description copied from class:ContextReturns the current process FULL_DUMP, DELTA_DUMP, FIND_DELTA- Specified by:
currentProcessin classContext- Returns:
- the type of the current running process
-
getRequestParameters
public Map<String,Object> getRequestParameters()
Description copied from class:ContextThe 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:
getRequestParametersin classContext- Returns:
- the request parameters passed in the URL to initiate this process
-
getEntityProcessor
public EntityProcessor getEntityProcessor()
Description copied from class:ContextReturns the instance of EntityProcessor used for this entity- Specified by:
getEntityProcessorin 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:ContextStore values in a certain name and scope (entity, document,global)- Specified by:
setSessionAttributein 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:Contextget a value by name in the given scope (entity, document,global)- Specified by:
getSessionAttributein 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:ContextGet 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:
getParentContextin classContext- Returns:
- parent entity's Context
-
getSolrCore
public SolrCore getSolrCore()
Description copied from class:ContextExposing the actual SolrCore to the components- Specified by:
getSolrCorein classContext- Returns:
- the core
-
getStats
public Map<String,Object> getStats()
Description copied from class:ContextMakes available some basic running statistics such as "docCount", "deletedDocCount", "rowCount", "queryCount" and "skipDocCount"
-
getScript
public String getScript()
Description copied from class:ContextReturns the text specified in the script tag in the data-config.xml
-
getScriptLanguage
public String getScriptLanguage()
Description copied from class:ContextReturns the language of the script as specified in the script tag in data-config.xml- Specified by:
getScriptLanguagein classContext
-
deleteDoc
public void deleteDoc(String id)
Description copied from class:Contextdelete a document by id
-
deleteDocByQuery
public void deleteDocByQuery(String query)
Description copied from class:Contextdelete documents by query- Specified by:
deleteDocByQueryin classContext
-
resolve
public Object resolve(String var)
Description copied from class:ContextUse this directly to resolve variable
-
replaceTokens
public String replaceTokens(String template)
Description copied from class:ContextResolve variables in a template- Specified by:
replaceTokensin classContext- Returns:
- The string w/ variables resolved
-
getLastException
public Exception getLastException()
-
setLastException
public void setLastException(Exception lastException)
-
-