InetSoft Product Information: Accessing POJO Data Sources Using InetSoft's BI System Software

The DataLoader2 interface is used to extract data which has a flat tabular structure as opposed to data with an inherent hierarchy. It is the simplest way to extract tabular data, without requiring any Data Helper class as it only deals with primitive data types. The DataLoader2 interface defines the following four methods:

1. public String[] getRequests()

    This method should return a list of request names. A request is tied to one set of output objects sharing the same class, and to one set of parameters. Requests are presented on the Data Modeler and are selected as part of a query.
    • e.g. public String[] getRequests() {return new String[] {"salesForEmployee", "salesForState"}; }

2. public ObjectMetaData getRequestOutput(String request)

    This method gets the output object type of a request. This method must support all requests returned from the getRequests() method.
    • e.g. public ObjectMetaData getRequestOutput(String request) {if(request.equals(“salesForEmployee“)) { return new ObjectMetaData(new String[] {"Employee", "Sales", "Year"}, new Class[] { (new String()).getClass(),(new Float(0)).getClass(),(new Integer(0)).getClass() }); }else if(request.equals(“salesForState“)){ .... }}
dashboard demo
View a 2-minute demonstration of InetSoft's easy, agile, and robust BI software.

3. public ObjectMetaData getRequestParameter(String request)

    This method gets the request parameter type. The parameter can be constructed when building a query and is passed to the data loaded in execute().
    • e.g. public ObjectMetaData getRequestParameter(String request) {if(request.equals(“salesForEmployee“)) { return new ObjectMetaData(new String[] {"fiscalYear"},new Class[] {(new Integer(0)).getClass()}); }else if(...) { ... }}

4. public Object execute(String request, VariableTable params, XSelection columns, XNodePath condition) throws ConditionNotSupportedException

    This method executes a request. If any condition is defined, the condition is passed to the execute method. The method may choose to handle the conditions, or throw a ConditionNotSupportedException. If the exception is thrown, the engine will call execute() again without the condition parameter passed in, and will handle the filtering as part of the post processing. The following return types are supported: XTable object, XTableNode object, or a two-dimensional array in which the first row serves as the column headers.
view gallery
View live interactive examples in InetSoft's dashboard and visualization gallery.

The Data Helper may be required under the following circumstances:

Your Data Loader is based on the (‘DataLoader’ interface or Introspection)

AND the return object class has only primitive attributes but does not follow the Java Bean naming conventions.

OR the return object class has any hierarchy.

The data helper class must implement the ‘inetsoft.uql.object.DataHelper’ interface, which defines the following two methods:

1. public XTypeNode[] getAttributes(Class cls)

    Given a class, this method should return an array of field types. Each type can be a primitive type such as those below, or a more complex type that represents an object tree:
    • string (inetsoft.uql.schema.StringType),
    • integer (inetsoft.uql.schema.IntegerType),
    • date (inetsoft.uql.schema.DateType), etc.

2. public Object getValue(Object obj, String name)

#1 Ranking: Read how InetSoft was rated #1 for user adoption in G2's user survey-based index Read More

    This method returns the value of a field. The name is the name of the field, and the obj parameter is the data object. The data helper overrides the introspection in two ways. At design time, introspection is not used to discover object fields. Instead, the getAttributes() method is called on the DataHelper to find the fields. At runtime, field values are returned using the getValue() method of the DataHelper, instead of calling the getter method on the data object itself. In order to define an object data source, all the necessary files need to be put into a directory, say an ‘object’ directory. The list of necessary files includes the
    • data loader class,
    • data helper class, if any, and
    • all the object classes.

The parent directory of this ‘object’ directory then needs to be included in the classpath.

Previous: Accessing Java Object Data Sources