org.apache.uima.fit.factory

## Class AggregateBuilder

- java.lang.Object
- - org.apache.uima.fit.factory.AggregateBuilder

-     public class AggregateBuilder
      extends Object

  This builder makes it easier to create an aggregate analysis engine. A typical use-case would involve initializing this builder with your preferred type system and type priorities (the latter may be null). This is followed by adding analysis engine descriptions one at a time until done. This makes it easy to have runtime decisions determine how the aggregate engine should be built. Finally, one of the create methods are called and an AnalysisEngine or AnalysisEngineDescription is returned.

  This is an example taken from our test cases:

       import static org.apache.uima.fit.factory.AnalysisEngineFactory.createPrimitiveDescription;

       AggregateBuilder builder = new AggregateBuilder();
       builder.add(createPrimitiveDescription(Annotator1.class, typeSystemDescription),
           ViewNames.PARENTHESES_VIEW, "A");
       builder.add(createPrimitiveDescription(Annotator2.class, typeSystemDescription),
           ViewNames.SORTED_VIEW, "B",
           ViewNames.SORTED_PARENTHESES_VIEW, "C",
           ViewNames.PARENTHESES_VIEW, "A");
       builder.add(createPrimitiveDescription(Annotator3.class, typeSystemDescription),
           ViewNames.INITIAL_VIEW, "B");
       AnalysisEngine aggregateEngine = builder.createAggregate();

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AggregateBuilder()` The default no-args constructor calls `AggregateBuilder(TypeSystemDescription, TypePriorities, FlowControllerDescription)` with null-valued args.
    `AggregateBuilder(org.apache.uima.resource.metadata.TypeSystemDescription typeSystemDescription, org.apache.uima.resource.metadata.TypePriorities typePriorities, org.apache.uima.flow.FlowControllerDescription flowControllerDescription)` Instantiate an AggregateBuilder with a given type system, type priorities, and flow controller.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `add(org.apache.uima.analysis_engine.AnalysisEngineDescription aed, String... viewNames)` This method simply calls `add(String, AnalysisEngineDescription, String...)` using the result of `AnalysisEngineDescription.getAnnotatorImplementationName()` for the component name
    `void` | `add(String componentName, org.apache.uima.analysis_engine.AnalysisEngineDescription aed, String... viewNames)`
    `void` | `addSofaMapping(String componentName, String componentViewName, String aggregateViewName)` Provide a sofa mapping for a component from the component's view to the aggregate view.
    `org.apache.uima.analysis_engine.AnalysisEngine` | `createAggregate()` This method simply delegates to `AnalysisEngineFactory.createEngine(List, TypeSystemDescription, TypePriorities, SofaMapping[], Object...)` with the data collected by this builder.
    `org.apache.uima.analysis_engine.AnalysisEngineDescription` | `createAggregateDescription()` This method simply delegates to `AnalysisEngineFactory.createEngineDescription(List, TypeSystemDescription, TypePriorities, SofaMapping[], Object...)` with the data collected by this builder.
    `void` | `setFlowControllerDescription(org.apache.uima.flow.FlowControllerDescription flowControllerDescription)` Set the flow controller description of the aggregate engine created by this builder.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AggregateBuilder

          public AggregateBuilder()

      The default no-args constructor calls `AggregateBuilder(TypeSystemDescription, TypePriorities, FlowControllerDescription)` with null-valued args.

    - #### AggregateBuilder

          public AggregateBuilder(org.apache.uima.resource.metadata.TypeSystemDescription typeSystemDescription,
                                  org.apache.uima.resource.metadata.TypePriorities typePriorities,
                                  org.apache.uima.flow.FlowControllerDescription flowControllerDescription)

      Instantiate an AggregateBuilder with a given type system, type priorities, and flow controller. Generally, speaking it suffices to use the no arguments constructor
      Parameters:
        `typeSystemDescription` - this can be instantiated using `TypeSystemDescriptionFactory`
        `typePriorities` - this can be instantiated using `TypePrioritiesFactory`
        `flowControllerDescription` - this can be instantiated using `FlowControllerFactory`

  - ### Method Detail

    - #### add

          public String add(org.apache.uima.analysis_engine.AnalysisEngineDescription aed,
                            String... viewNames)

      This method simply calls `add(String, AnalysisEngineDescription, String...)` using the result of `AnalysisEngineDescription.getAnnotatorImplementationName()` for the component name
      Parameters:
        `aed` - an analysis engine description to add to the aggregate analysis engine
        `viewNames` - pairs of view names corresponding to a componentSofaName followed by the aggregateSofaName that it is mapped to. An even number of names must be passed in or else an IllegalArgumentException will be thrown. See `SofaMappingFactory.createSofaMapping(String, String, String)`
      Returns:
        the name of the component generated for the `AnalysisEngineDescription`

    - #### add

          public void add(String componentName,
                          org.apache.uima.analysis_engine.AnalysisEngineDescription aed,
                          String... viewNames)

      Parameters:
        `componentName` - the name of the component to add
        `aed` - an analysis engine description to add to the aggregate analysis engine
        `viewNames` - pairs of view names corresponding to a componentSofaName followed by the aggregateSofaName that it is mapped to. An even number of names must be passed in or else an IllegalArgumentException will be thrown. See `SofaMappingFactory.createSofaMapping(String, String, String)`

    - #### addSofaMapping

          public void addSofaMapping(String componentName,
                                     String componentViewName,
                                     String aggregateViewName)

      Provide a sofa mapping for a component from the component's view to the aggregate view.
      Parameters:
        `componentName` - the name of the component
        `componentViewName` - the name of the component view
        `aggregateViewName` - the name of the aggregate view to map the component view to.

    - #### setFlowControllerDescription

          public void setFlowControllerDescription(org.apache.uima.flow.FlowControllerDescription flowControllerDescription)

      Set the flow controller description of the aggregate engine created by this builder.
      Parameters:
        `flowControllerDescription` - see `FlowControllerFactory`

    - #### createAggregate

          public org.apache.uima.analysis_engine.AnalysisEngine createAggregate()
                                                                         throws org.apache.uima.resource.ResourceInitializationException

      This method simply delegates to `AnalysisEngineFactory.createEngine(List, TypeSystemDescription, TypePriorities, SofaMapping[], Object...)` with the data collected by this builder.
      Returns:
        an aggregate analysis engine
      Throws:
        `org.apache.uima.resource.ResourceInitializationException` - if there is a problem during initialization

    - #### createAggregateDescription

          public org.apache.uima.analysis_engine.AnalysisEngineDescription createAggregateDescription()
                                                                                               throws org.apache.uima.resource.ResourceInitializationException

      This method simply delegates to `AnalysisEngineFactory.createEngineDescription(List, TypeSystemDescription, TypePriorities, SofaMapping[], Object...)` with the data collected by this builder.
      Returns:
        a description of an aggregate analysis engine
      Throws:
        `org.apache.uima.resource.ResourceInitializationException` - if there is a problem during initialization

Copyright © 2012–2020 The Apache Software Foundation. All rights reserved.