org.apache.solr.handler.dataimport

## 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 and 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 and 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 and Description
    --- | ---
    `String` | `currentProcess()` Returns the current process FULL_DUMP, DELTA_DUMP, FIND_DELTA
    `void` | `deleteDoc(String id)` delete a document by id
    `void` | `deleteDocByQuery(String query)` delete documents by query
    `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.
    `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
    `Exception` | `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 value
    `String` | `getScript()` Returns the text specified in the script tag in the data-config.xml
    `String` | `getScriptLanguage()` Returns the language of the script as specified in the script tag in data-config.xml
    `Object` | `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 components
    `Map<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 entity
    `String` | `replaceTokens(String template)` Resolve variables in a template
    `Object` | `resolve(String var)` Use this directly to resolve variable
    `void` | `setLastException(Exception lastException)`
    `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`

- - ### 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 class `Context`
      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 class `Context`
      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 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 ${<namespce.name>}
      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 String currentProcess()

      Description copied from class: `Context`
      Returns the current process FULL_DUMP, DELTA_DUMP, FIND_DELTA
      Specified by:
        `currentProcess` in class `Context`
      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 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 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 class `Context`
      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 class `Context`
      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"
      Specified by:
        `getStats` in class `Context`
      Returns:
        a Map containing running statistics of the current import

    - #### getScript

          public String getScript()

      Description copied from class: `Context`
      Returns the text specified in the script tag in the data-config.xml
      Specified by:
        `getScript` in class `Context`

    - #### 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 class `Context`

    - #### deleteDoc

          public void deleteDoc(String id)

      Description copied from class: `Context`
      delete a document by id
      Specified by:
        `deleteDoc` in class `Context`

    - #### deleteDocByQuery

          public void deleteDocByQuery(String query)

      Description copied from class: `Context`
      delete documents by query
      Specified by:
        `deleteDocByQuery` in class `Context`

    - #### resolve

          public Object resolve(String var)

      Description copied from class: `Context`
      Use this directly to resolve variable
      Specified by:
        `resolve` in class `Context`
      Parameters:
        `var` - the variable name
      Returns:
        the resolved value

    - #### replaceTokens

          public String replaceTokens(String template)

      Description copied from class: `Context`
      Resolve variables in a template
      Specified by:
        `replaceTokens` in class `Context`
      Returns:
        The string w/ variables resolved

    - #### getLastException

          public Exception getLastException()

    - #### setLastException

          public void setLastException(Exception lastException)

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.