org.apache.solr.handler.dataimport

## Class Context

- java.lang.Object
- - org.apache.solr.handler.dataimport.Context

- Direct Known Subclasses:
    ContextImpl

      public abstract class Context
      extends Object

  This abstract class gives access to all available objects. So any component implemented by a user can have the full power of DataImportHandler

  Refer to http://wiki.apache.org/solr/DataImportHandler for more details.

  This API is experimental and subject to change

  Since:
    solr 1.3

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DELTA_DUMP`
    `static String` | `FIND_DELTA`
    `static String` | `FULL_DUMP`
    `static String` | `SCOPE_DOC` An object stored in document scope is available for the current document only but across entities.
    `static String` | `SCOPE_ENTITY` An object stored in entity scope is valid only for the current entity for the current document only.
    `static String` | `SCOPE_GLOBAL` An object stored in global scope is available for the current import only but across entities and documents.
    `static String` | `SCOPE_SOLR_CORE` An object stored in 'solrcore' scope is available across imports, entities and documents throughout the life of a solr core.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Context()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract String` | `currentProcess()` Returns the current process FULL_DUMP, DELTA_DUMP, FIND_DELTA
    `abstract void` | `deleteDoc(String id)` delete a document by id
    `abstract void` | `deleteDocByQuery(String query)` delete documents by query
    `abstract List<Map<String,String>>` | `getAllEntityFields()` Returns all the fields put into an entity.
    `abstract DataSource` | `getDataSource()` Gets the datasource instance defined for this entity.
    `abstract DataSource` | `getDataSource(String name)` Gets a new DataSource instance with a name.
    `abstract String` | `getEntityAttribute(String name)` Get the value of any attribute put into this entity
    `abstract EntityProcessor` | `getEntityProcessor()` Returns the instance of EntityProcessor used for this entity
    `abstract Context` | `getParentContext()` Get the context instance for the parent entity.
    `abstract 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)
    `abstract String` | `getResolvedEntityAttribute(String name)` Get the value of any attribute put into this entity after resolving all variables found in the attribute value
    `abstract String` | `getScript()` Returns the text specified in the script tag in the data-config.xml
    `abstract String` | `getScriptLanguage()` Returns the language of the script as specified in the script tag in data-config.xml
    `abstract Object` | `getSessionAttribute(String name, String scope)` get a value by name in the given scope (entity, document,global)
    `abstract SolrCore` | `getSolrCore()` Exposing the actual SolrCore to the components
    `abstract Map<String,Object>` | `getStats()` Makes available some basic running statistics such as "docCount", "deletedDocCount", "rowCount", "queryCount" and "skipDocCount"
    `abstract VariableResolver` | `getVariableResolver()` Returns the VariableResolver used in this entity which can be used to resolve the tokens in ${<namespce.name>}
    `abstract boolean` | `isRootEntity()` Returns if the current entity is the root entity
    `abstract String` | `replaceTokens(String template)` Resolve variables in a template
    `abstract Object` | `resolve(String var)` Use this directly to resolve variable
    `abstract 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

    - #### FULL_DUMP

          public static final String FULL_DUMP

      See Also:
        Constant Field Values

    - #### DELTA_DUMP

          public static final String DELTA_DUMP

      See Also:
        Constant Field Values

    - #### FIND_DELTA

          public static final String FIND_DELTA

      See Also:
        Constant Field Values

    - #### SCOPE_ENTITY

          public static final String SCOPE_ENTITY

      An object stored in entity scope is valid only for the current entity for the current document only.
      See Also:
        Constant Field Values

    - #### SCOPE_GLOBAL

          public static final String SCOPE_GLOBAL

      An object stored in global scope is available for the current import only but across entities and documents.
      See Also:
        Constant Field Values

    - #### SCOPE_DOC

          public static final String SCOPE_DOC

      An object stored in document scope is available for the current document only but across entities.
      See Also:
        Constant Field Values

    - #### SCOPE_SOLR_CORE

          public static final String SCOPE_SOLR_CORE

      An object stored in 'solrcore' scope is available across imports, entities and documents throughout the life of a solr core. A solr core unload or reload will destroy this data.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Context

          public Context()

  - ### Method Detail

    - #### getEntityAttribute

          public abstract String getEntityAttribute(String name)

      Get the value of any attribute put into this entity
      Parameters:
        `name` - name of the attribute eg: 'name'
      Returns:
        value of named attribute in entity

    - #### getResolvedEntityAttribute

          public abstract String getResolvedEntityAttribute(String name)

      Get the value of any attribute put into this entity after resolving all variables found in the attribute value
      Parameters:
        `name` - name of the attribute
      Returns:
        value of the named attribute after resolving all variables

    - #### getAllEntityFields

          public abstract List<Map<String,String>> getAllEntityFields()

      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
      Returns:
        all fields in an entity

    - #### getVariableResolver

          public abstract VariableResolver getVariableResolver()

      Returns the VariableResolver used in this entity which can be used to resolve the tokens in ${<namespce.name>}
      Returns:
        a VariableResolver instance
      See Also:
        `VariableResolver`

    - #### getDataSource

          public abstract DataSource getDataSource()

      Gets the datasource instance defined for this entity. Do not close() this instance. Transformers should use the getDataSource(String name) method.
      Returns:
        a new DataSource instance as configured for the current entity
      See Also:
        `DataSource`, `getDataSource(String)`

    - #### getDataSource

          public abstract DataSource getDataSource(String name)

      Gets a new DataSource instance with a name. Ensure that you close() this after use because this is created just for this method call.
      Parameters:
        `name` - Name of the dataSource as defined in the dataSource tag
      Returns:
        a new DataSource instance
      See Also:
        `DataSource`

    - #### getEntityProcessor

          public abstract EntityProcessor getEntityProcessor()

      Returns the instance of EntityProcessor used for this entity
      Returns:
        instance of EntityProcessor used for the current entity
      See Also:
        `EntityProcessor`

    - #### setSessionAttribute

          public abstract void setSessionAttribute(String name,
                                                   Object val,
                                                   String scope)

      Store values in a certain name and scope (entity, document,global)
      Parameters:
        `name` - the key
        `val` - the value
        `scope` - the scope in which the given key, value pair is to be stored

    - #### getSessionAttribute

          public abstract Object getSessionAttribute(String name,
                                                     String scope)

      get a value by name in the given scope (entity, document,global)
      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 abstract Context getParentContext()

      Get the context instance for the parent entity. works only in the full dump If the current entity is rootmost a null is returned
      Returns:
        parent entity's Context

    - #### getRequestParameters

          public abstract 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)
      Returns:
        the request parameters passed in the URL to initiate this process

    - #### isRootEntity

          public abstract boolean isRootEntity()

      Returns if the current entity is the root entity
      Returns:
        true if current entity is the root entity, false otherwise

    - #### currentProcess

          public abstract String currentProcess()

      Returns the current process FULL_DUMP, DELTA_DUMP, FIND_DELTA
      Returns:
        the type of the current running process

    - #### getSolrCore

          public abstract SolrCore getSolrCore()

      Exposing the actual SolrCore to the components
      Returns:
        the core

    - #### getStats

          public abstract Map<String,Object> getStats()

      Makes available some basic running statistics such as "docCount", "deletedDocCount", "rowCount", "queryCount" and "skipDocCount"
      Returns:
        a Map containing running statistics of the current import

    - #### getScript

          public abstract String getScript()

      Returns the text specified in the script tag in the data-config.xml

    - #### getScriptLanguage

          public abstract String getScriptLanguage()

      Returns the language of the script as specified in the script tag in data-config.xml

    - #### deleteDoc

          public abstract void deleteDoc(String id)

      delete a document by id

    - #### deleteDocByQuery

          public abstract void deleteDocByQuery(String query)

      delete documents by query

    - #### resolve

          public abstract Object resolve(String var)

      Use this directly to resolve variable
      Parameters:
        `var` - the variable name
      Returns:
        the resolved value

    - #### replaceTokens

          public abstract String replaceTokens(String template)

      Resolve variables in a template
      Returns:
        The string w/ variables resolved

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