Page tree
Skip to end of metadata
Go to start of metadata

Overview

The AIE Administrator creates a form-based editor for every component, transformer, and scanner, including those created or customized by the user. 

The generated form includes a field for each spring property exposed on the given class. In practice, each property of the Java class that has a pair of get() and set() methods will appear as a field in the editor.

This page describes how to invoke this mechanism, and how to add annotations to the Java code to make the labeling and interfacing more graceful. 

View incoming links.

Registering Custom Classes

Your custom Java classes (scanners, transformers and other components) can be configured dynamically using editors in the AIE Administrator.  You can expose your custom classes in the AIE Administrator through the <project-dir>\src\attivio.module.xml file. 

The syntax of the file is very simple:

<project-dir>\src\attivio.module.xml
<attivio>
  <module name="module-plusjava" version="-1">
    <description>Module containing sample SDK code.</description>
    <connectors>
      <connector name="samplescanner" class="com.acme.examples.SampleScanner"/>
    </connectors>
    <components>
      <component class="com.acme.SampleAdvancedIngestTransformer"/>
      <component class="com.acme.SampleQueryTransformer"/>
      <component class="com.acme.SampleResponseTransformer"/>
      <component class="com.acme.SampleSimpleIngestTransformer"/>
    </components>
  </module>
</attivio>

Custom scanners are registered in the <connectors> section.  Other components can be registered in the <components> section. 

Configure Properties

To prepare a Java class for dynamic configuration, set up each of the settable properties as a Java class "field," meaning a variable that is defined at the class level.  For instance, consider the field and value properties in the DemoFieldTransformer.java example from the Java Server API page. :

<project-dir>\src\com\acme\server\DemoFieldTransformer.java
public class DemoFieldTransformer implements DocumentModifyingTransformer {

    private String field = FieldNames.TABLE;
    private String value = "Hello World!";

This example added the value "Hello World!" to a document's table field.  These properties (field and value) were hard-coded in the original example, but can be set dynamically through the AIE Administrator Component Editor.  

In the following code snippet, the DemoFieldTransformer class exposes the two properties through getter and setter methods named after the fields.  This means that the field property has getField() and setField() methods, and the value property has getValue() and setValue() methods.

<project-dir>\src\com\acme\server\DemoFieldTransformer.java
      public String getField() {
        return field;
      }
      public void setField(String field) {
        this.field = field;
      }
      
      public String getValue() {
        return value;
      }
      public void setValue(String value) {
        this.value = value;
      }

Configure in an Editor

AIE relies on this naming convention to generate editors for custom objects. It does this by looking at the data type returned by the "get" method and mapping it to an appropriate editor control.  This mechanism handles all base data types (string, int, long, float, double, boolean) in addition to java.util.Map and java.util.List collections of primitive types. All that is required is that the getter and setter methods be present for properties with these datatypes.

For instance, the DemoFieldTransformer properties are both strings.  When we edit the DemoFieldTransformer in the AIE Administrator, these properties automatically appear in the editor:

 

Configuring Editor Controls

The default convention of using the "get" and "set" methods to generate fields in the editor (as in the previous example) produces edit fields that are tersely named after Java variables. A UI designer might want to put a friendlier face on this.

To make the labeling friendlier and the fields more sophisticated, AIE provides Java annotations from the AIE Annotation  package.  These are Java annotations added to the class definition to control how classes and parameters are presented and configured in the editors of the AIE Administrator.


ConfigurationOption

The ConfigurationOption  annotation describes the behavior of individual properties in the AIE Administration editors and, in the case of scanners, on the command line.  Insert this annotation just before the "get" method of a specific property.


<project-dir>\src\com\acme\server\DemoFieldTransformer.java
      @ConfigurationOption(displayName="Value to add:",
              description = "Enter value string.", 
              hidden = false, 
              formEntryClass=ConfigurationOption.PASSWORD)
      
      public String getValue() {
        return value;
      }

ConfigurationOptionResults

ConfigurationOption has four properties:

  • displayName - Sets/renames the property. Shows up as the label next to the edit field.
  • description - A detailed description of the property. Shows up as the tooltip when you hover the mouse over the control.
  • hidden - Prevents this property from being displayed in the AIE Administrator editor.
  • formEntryClass - Assigns a special edit control to a given property, such as a list control or a password control. Options are defined with reference to the ConfigurationOptionEntries class, as in ConfigurationOptionEntries.PASSWORD:
    • STRING_LIST - Use for methods that return List<string>.
    • STRING_TO_STRING_MAP - Use for MAP<String,String> methods.
    • SPRING_BEAN - Use for any object that should be pulled from spring.
    • PASSWORD - Use for any String method that should be rendered as a password.
    • TEXT_AREA - Use for any String method that needs a large field for text.
    • HTTPS - Use for any String method that should be rendered as an HTTP or HTTPS option box.
    • SORTED_STRING_LIST - Use for methods that return List<string>. Automatically sorts the list.

ConfigurationOptionInfo

AIE also provides the ConfigurationOptionInfo  annotation, which is used to define class-level configuration.


For instance, the following annotation could be placed just above the DemoFieldTransformer class definition.  The annotation assigns the new transformer a displayName and description, to make it easy to identify in a long list of components.  Then it allocates the transformer's parameters (field and value) to two customized "groups" on separate tabs of the Component Editor.

<project-dir>\com\acme\server\DemoFieldTransformer.java
@ConfigurationOptionInfo(
        displayName = "DemoFieldTransformer",
        description = "Simplest possible field transformer.",
        groups = {
            @ConfigurationOptionInfo.Group(path = 
                {ConfigurationOptionInfo.PLATFORM_COMPONENT,"Custom Parameters"},
                propertyNames = {"field"} ),
            @ConfigurationOptionInfo.Group(path = 
                {ConfigurationOptionInfo.OTHER,"Custom Values"},
                propertyNames = {"value"} )
            }
        )
public class DemoFieldTransformer implements DocumentModifyingTransformer {
    private String field = FieldNames.TABLE;
    private String value = "Hello World!";

The displayName and description are visible in the New Component selection list:

NewComponentDBox

The first group definition places the field property on the Platform Component tab of the Component Editor, under the subheading "Csutom Parameters."  The second group places the value property on the Other tab of the editor, under the "Custom Values" subheading. 

CustomGroups

The ConfigurationOptionInfo annotation has several properties:

  • displayName - Sets/renames the component. Defaults to classname if not set.
  • description - Detailed description of component. Used in the "new component" list to help the user select the right component.
  • groups - Used to control the layout and order of the custom properties within the form. The value is a string array of one or more Group annotations.
    • Group.path - This is a string array of one or two elements which determines where to display the properties of this group. The first position of the array is the tab name, which must be one of the values listed below. Options are defined as properties of the ConfigurationOptionsInfo class, as in ConfigurationOptionInfo.OTHER:
      • ADVANCED
      • FIELD_MAPPINGS
      • MESSAGE_PUBLISHER
      • SCANNER
      • PLATFORM_COMPONENT
      • SECURITY
      • OTHER
    • The second element of the group path is the optional sub-section heading. Give a new sub-section any name you prefer, expressed as a string.  To add properties to an existing sub-heading (such as "Endpoints" on the "Advanced" tab) use the ConfigurationOptionInfo properties below:
      • ENDPOINTS
      • INCREMENTAL
    • Group.propertyNames - is a string array of the properties to display in this group.  Order is significant.

 

  • No labels