org.apache.solr.handler.dataimport
Class ContextImpl

java.lang.Object
  extended by org.apache.solr.handler.dataimport.Context
      extended by 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
Version:
$Id: ContextImpl.java 693621 2008-09-09 21:20:40Z gsingers $

Field Summary
 
Fields inherited from class org.apache.solr.handler.dataimport.Context
DELTA_DUMP, FIND_DELTA, FULL_DUMP, SCOPE_DOC, SCOPE_ENTITY, SCOPE_GLOBAL
 
Constructor Summary
ContextImpl(DataConfig.Entity entity, VariableResolverImpl resolver, DataSource ds, int currProcess, Map<String,Object> requestParams, Map<String,Object> global, ContextImpl p, DataImporter di)
           
 
Method Summary
 int currentProcess()
          Returns the current process FULL_DUMP =1, DELTA_DUMP=2, FIND_DELTA=3
 List<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.
 Map<String,Object> getDocSession()
           
 String getEntityAttribute(String name)
          Get the value of any attribute put into this entity
 EntityProcessor getEntityProcessor()
          Returns the instance of EntityProcessor used for this entity
 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 (for multi-valued parameters)
 Object getSessionAttribute(String name, String scope)
          get a value by name in the given scope (entity, document,global)
 org.apache.solr.core.SolrCore getSolrCore()
          Exposing the actual SolrCore to the components
 VariableResolver getVariableResolver()
          Returns the VariableResolver used in this entity which can be used to resolve the tokens in ${}
 boolean isRootEntity()
          Returns if the current entity is the root entity
 void setDocSession(Map<String,Object> docSession)
           
 void setSessionAttribute(String name, Object val, String scope)
          Store values in a certain name and scope (entity, document,global)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextImpl

public ContextImpl(DataConfig.Entity entity,
                   VariableResolverImpl resolver,
                   DataSource ds,
                   int currProcess,
                   Map<String,Object> requestParams,
                   Map<String,Object> global,
                   ContextImpl p,
                   DataImporter di)
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 class Context
Parameters:
name - name of the attribute eg: 'name'
Returns:
value of named attribute in entity

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 class Context
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 ${}

Specified by:
getVariableResolver in class Context
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 class Context
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 class Context
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 class Context
Returns:
true if current entity is the root entity, false otherwise

currentProcess

public int currentProcess()
Description copied from class: Context
Returns the current process FULL_DUMP =1, DELTA_DUMP=2, FIND_DELTA=3

Specified by:
currentProcess in class Context
Returns:
the code 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 (for multi-valued parameters)

Specified by:
getRequestParameters in class Context
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 class Context
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 class Context
Parameters:
name - the key
val - the value
scope - 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 class Context
Parameters:
name - the key
scope - the scope from which the value is to be retreived
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 class Context
Returns:
parent entity's Context

getDocSession

public Map<String,Object> getDocSession()

setDocSession

public void setDocSession(Map<String,Object> docSession)

getSolrCore

public org.apache.solr.core.SolrCore getSolrCore()
Description copied from class: Context
Exposing the actual SolrCore to the components

Specified by:
getSolrCore in class Context
Returns:
the core


Copyright © 2008 Apache Software Foundation. All Rights Reserved.