NetCharts Server Process Modules
Table of Contents
- Introduction
- Preparation
- Process Module Features
- A Process Module Example
- Best Practices
- Example 1 – DataMultiply.java
- Example 2 – DataMultiplyInfo.java
- Where can I go for additional resources and help?
Introduction
Scope
This document is intended for NetCharts Server and NetCharts Designer application developers and contains information and examples for writing custom Process Modules. A Process Module is used to apply custom data transformation to a dataset after data retrieval, but before presentation. Process Modules are written in the Java language and require at least basic Java proficiency.
Background
Presentation data, residing in databases or other data stores, is often not in an appropriate form for display in visual or tabular form. For example, a database may contain a table of sales records, but the end user is interested in viewing the difference between aggregate monthly sales over the same period in the previous year. Or perhaps the user wants to see the rate of change on a per-month basis. Alternatively, it could be as simple as needing to divide big numbers ($1,746.354) into smaller representations ($1.7M) to fit into a smaller, more visually appealing table.
Many applications traditionally attempt to address data shortfalls thru the use of stored procedures, summary tables, or other database-centric solutions. This approach may require unique skills (database programming) and tends to be a “one-off” solution for each data set. Other tactics involve building all of the computation features into the presentation layer, resulting in slow, hard-to-maintain, bloated client software. The use of Process Modules allow for creating reuable methods within the application.
The Process Module Feature
Data Processing
To address the data transformation problem, NetCharts Server and NetCharts Designer support a feature known as Process Modules. Each Process Module is a self-contained segment of Java code that takes a simple object array of data and a set of configuration parameters as input, and outputs an object array of the modified data.
At runtime, the Process Module is inserted into the reporting process after the data has been retrieved from the data store, but before any visual or tabular rendering has begun. This allows the same Process Module to be applied to any back end data store as well as allowing the modified data to be used for any presentation component (e.g. chart or table). Multiple Process Modules may be “chained” together so that derived columns can be used in subsequent calculations.
Process Modules are available anytime a graph, table, or the NetCharts Server API requests a Named Data Set (NDS/NDX) file in order to get data. NDS files identify a data source and supply the necessary configuration parameters to extract data. After a Process Module has been written and registered with NetCharts Server, parameters are added to the NDS to direct the data flow to the Process Module.
Graphical User Interface (GUI)
In order to provide easy integration of Process Modules into the NetCharts Designer, developers have access to an Info API to describe the Process Module and its parameters. When the Process Module is registered with NetCharts Designer, a GUI is automatically generated using the API description. The GUI is then available for the NetCharts Designer user, for easy and intuitive application of the Process Module on data sources.
Preparation
Existing Process Modules
NetCharts provides many Process Modules, so you may not need to write your own.
Basic Modules
The following Process Modules are supplied pre-loaded with NetCharts Server and Designer 4.6 (or later):
Name |
Function |
Basic Column Math | Add/Subtract/Divide/Multiply a numerical constant against column values |
Column Data Joiner | Joins two columns together with a given delimiter |
Column By Column Multiplier | Multiplies two columns together |
Conditional Colors | Creates a column of colors dependant on data values. |
Data Aggregation | Sum/Average/Min/Max for a dataset |
Data Filter | Reduces the size of the dataset |
Data Pivot | Performs a grouping/realignment of data based on column values |
Data Sort | Sorts the dataset based on the contents of a column |
Keyword Sort | Arranges data based on full or partial keywords found in a column |
Transpose Data | “Flips” the dataset so the column headers become row headers and vice versa |
Analytics Modules
NetCharts Analytics contains over 50 unique Process Modules covering general data manipulation methods as well as sophisticated functions for calculus, finance, statistics, and Statistical Process Control (SPC).
Knowledge Base
As Visual Mining staff develops Process Modules, we will review and post them to our support Knowledge Base for free download for customers under a current maintenance contract. Some of the existing functions are:
Name |
Function |
Column Number Format | Applies a numerical format to one or more columns |
Data Pivot2 | An improved version of the bundled Data Pivot |
Data Rollup | Does a GROUP BY type function with sub-totals |
NDSMerge | Does a JOIN type function based on common fields in two unique NDX’s |
ParentChildLayout | Converts parent->child data into nodes and edges for easy diagramming |
Development Requirements
Before beginning, you should ensure the following:
- NetCharts Server version 4.6 (or later) has been installed on your machine and is functioning properly
- You have downloaded and installed a Java Software Development Kit (SDK). If you do not have a SDK (1.4 JVM or later), you can download one from http://www.oracle.com/technetwork/java/javase/downloads/index.html. You will need to download and install the Software Development Kit (SDK), not the JRE.
Process Module Features
The NetCharts Process Module system contains several components. There are Java interface files that describe the Application Programmer’s Interface (API) into the Process Module, there is the PROCESSMODULE keyword for debug information, and there are interfaces in both NetCharts Server and NetCharts Designer to make the import and management of Process Modules simple.
Application Programmers Interface (API)
The Javadoc for this API can be found in the NetCharts Server online documentation set under the NetCharts Server API Docs section.
netcharts.server.api.NDSPostProcessorInterface
This interface must be implemented by all Process Modules. It performs the run-time work of the Process Module.
Method |
Purpose |
public Object[][] processNDS(Object data[][], Hashtable parameters, int nth); | Takes an input data array along with a parameter hashtable and generates an output data array. |
netcharts.server.api.NDSPostProcessorInterfaceInfoV2
The Info interface is used to describe the Process Module GUI. Each implementation of the Info interface allows a description of the function and list of the function’s parameters as defined in the parameter info interface below.
Method |
Purpose |
public String getName(); | Returns the descriptive name of the Process Module. |
public String getDescription(); | Returns a more detailed description of the Process Module. |
public boolean getIsIndexed(); | Indicates if there can be more than one instance of the Process Module within the same process chain. |
public NDSPostProcessorInterfaceParameterInfo[] getParameters(); | Returns an array of objects representing each expected input parameter |
public Hashtable getAdditionalParameters(); | Returns an array of parameter objects that the Process Module uses but that should not be editable. |
public String getCategory(); | Get the name of the Process Module category. This can be used to group related Process Modules in the GUI. |
public String getSubCategory(); | Get the name of the Process Module subcategory. This can be used to group related Process Modules in the GUI. (not implemented in 4.6) |
netcharts.server.api.NDSPostProcessInterfaceParameterInfoV2
The parameter info interface is used to describe each parameter and provide type information so that the GUI provides the appropriate controls to get input from the user.
Method |
Purpose |
public String getCustomConfigurationClass(String displayType); | Returns the class that will be used to configure the parameter information. For internal Visual Mining use only. |
public int getType(); | Returns TEXT, OPTION |
public String getParameter(); | This is the parameter name used by the Process Module |
public String getDisplayName(); | This is the parameter name shown to the user |
public String[] getOptionValues(); | Returns the set of possible values if the parameter is of type OPTION |
public boolean removeParameterIfEmpty(); | Instructs NetCharts Designer to remove the parameter from the set if an empty value is entered. |
public NDSPostProcessorInterfaceParameterValidator getValidator(); | Allows the assignment of a validator class to accept/reject user entries. |
Debugging Interface
NetCharts Server and NetCharts Designer both provide displays for system logging and NFDebug messages.
netcharts.util.NFDebug Interface
The NFDebug interface is a utility built into the core NetCharts library that allows debug messages to inserted into code but not activated unless the debugging is turned on and the category keyword is selected. A special keyword, PROCESSMODULE, has been added to the NFDebug API for output of Process Module related messages. The following is a sample code segment of NFDebug message extracted from the example program in the next section:
NFDebug.print(NFDebug.PROCESSMODULE, “DataMultiply: multiplyColumnIndex set to “+indexString);
NetCharts Designer Debugging/Logging Interface
NetCharts Designer provides two separate views – a System Log Viewer and a NetCharts Designer Debugging panel. Both may be opened by going to the main menu and selecting Window->Show View->Other, opening the “NetCharts Designer” tree, and selecting either System Log Viewer or NetCharts Designer Debugging Panel. (once opened, both may be dragged onto the preview panel to consolidate the views). Both debugging panels have assorted controls. The Log Viewer has controls for clearing or copying the display; the Debugging Panel allows users to delete the log file, and set filter options.
The System Log Viewer is populated with messages written to stderr or stdout. The Debugging Panel only shows messages written to NFDebug.
NetCharts Server Debugging/Logging Interface
Like NetCharts Designer, NetCharts Server also provides access to stdout, stderr, and NFDebug messages. In NetCharts Server, the log files are accessible from the Developer’s or Administrators consoles under the “Debug/Logging” category. NFDebug messages are written and controlled from the “Debug” link. “Error Log” displays those messages written to stderr, and “Message Log” displays messages written to stdout.
Process Modules Registration
To use Process Modules within an application they must be loaded and registered within the NetCharts Designer and NetCharts Server installations that they will be developed with and deployed on. Both NetCharts Designer and NetCharts Server provide utilities to make the registration and deregistration of Process Modules straightforward.
Registering Process Modules – NetCharts Designer
In NetCharts Designer, Process Modules are registered by selecting the right mouse button over the Designer Navigator window and then selecting “NetCharts Designer -> Import Process Modules…”
Then, once the Import Dialog appears, select the appropriate Process Module JAR files and click theFinish button. The Process Modules will be loaded and will be available after a Designer restart.
Registering Process Modules – NetCharts Server
In NetCharts Server, Process Modules may be registered simply by going to the Admin Console and selecting the Import JAR Files option. After selecting the appropriate JAR and clicking the Uploadbutton, the Process Modules will be registered. After a NetCharts Server restart the Process Module will be available for use.
Removing Process Modules
It is sometimes necessary to explicitly remove Process Modules.
In NetCharts Designer, select the right mouse button over the Designer Navigator window and then choose the “NetCharts Designer->Remove Process Modules…” option. Then select the JAR file to remove and the Process Modules will be deregistered and completely unavailable after a NetCharts Designer restart.
In NetCharts Server select the Remove JAR Files option. After selecting the appropriate JAR the Process Modules will be removed. After a NetCharts Server restart, they will be unavailable for further use.
A Process Module Example
In this section, we will create all the elements to build a Process Module. In this example, we will create a working version of a Process Module that can be used to multiply or divide column data by a constant value. We assume a generic Java development environment on a Windows XP based platform; however it should not be difficult to use an alternative environment if desired.
Setting Up a Development Environment
Start by creating a separate directory on your ‘C’ drive called NCSDevelopment. In that directory, create a text file called setuppath.bat. Using a plain text editor (don’t use Notepad), edit that file and enter in the following :
set path=c:\j2sdk1.4.2_03\bin;%PATH%
set CLASSPATH=.\;C:\Program Files\Visual Mining\NetCharts Designer 7.0\plugins\netcharts.designer\server\common\lib\ncs.jar;C:\Program Files\Visual Mining\NetCharts Designer 7.0\plugins\netcharts.designer\server\common\lib\netcharts.jar
When executed, setuppath.bat will configure a command prompt to be able to find dependant files.
Next, create another text file in the NCSDevelopment directory called makejar.bat. Edit the file and enter in:
javac -d .\ *.java
jar -cf ExampleProcessModules.jar com\visualmining\example\processmodules\*.class
makejar.bat, when executed, will compile a Java file, and put the result into a Java Archive (JAR) file.
Now let’s create the Java files. We’ll start by creating the file that will be called at runtime. Create a text file in the directory and name it DataMultiply.java. Edit the file and enter the following:
package com.visualmining.example.processmodules;
import java.util.Hashtable;
import netcharts.util.NFDebug;
import netcharts.server.api.NDSPostProcessorInterface;
public class DataMultiply implements NDSPostProcessorInterface
{
public Object[][] processNDS(Object indata[][], Hashtable params, int nth){
Object outdata[][] = indata;
return outdata;
}
}
We’ll stop at this point to test our setup before we write too much more code. Using a command prompt go into the C:\NCSDevelopment directory. Type setuppath and hit enter. Then type makejarand hit enter. At this point, the .java file should compile and a file named ExampleProcessModules.jarshould be created.
Writing the Process Module Content
Let’s look at our code so far.
All Process Modules must implement the NDSPostProcessorInterface, which has one method,processNDS. The method processNDS has three inputs, indata, params, and nth.
- indata represents the data coming from the data store or possibly from another Process Module.
- params is a Hashtable of all the configuration parameters passed to the NDS. If the Process Module requires runtime parameters, this Hashtable can be used to supply them from the NDS file.
- nth is an index that identifies how many times this Process Module has been called in this particular NDS instance. This is useful if the NDS file must contain multiple sets of parameters for each time the Process Module is called.
Let’s go ahead now and write the rest of the code.
First, change the line :
Object outdata[][] = indata;
to:
if (indata == null || indata.length < 1) return indata;
This will ensure if there is no input data, no action will be taken. Now add the remainder:
// create an output structure the same
// size as the input plus the output column.
Object outdata[][] = new Object[indata.length][indata[0].length+1];
int newColIndex = indata[0].length;
int columnIndex = 0;
double multiplier = 1.0;
boolean hasColumnNames = false;
try {
// Check to see if the original data set has column names. If so we’ll
// need to insert a column name
String includeColNames = (String)params.get(“includeColumnNames”);
hasColumnNames = (includeColNames != null && includeColNames.equalsIgnoreCase(“true”));
// check for the parameter “dataMultiplyEnable”. This will allow the user
// to disable/enable this function if desired.
String enabled= (String)params.get(“dataMultiplyEnable”+nth);
if (enabled != null && enabled.equalsIgnoreCase(“false”)) {
return indata;
}
// get the index of the column and the multiplier parameters from
// the NDS parameter hashtable.
String indexString = (String)params.get(“dataMultiplyColumnIndex”+nth);
String multiplierNumber = (String)params.get(“dataMultiplyMultiplier”+nth);
// write a debug statement
NFDebug.print(NFDebug.PROCESSMODULE, “DataMultiply: multiplyColumnIndex set to “+indexString);
// convert the parameters into their numerical equivalents
columnIndex = Integer.parseInt(indexString);
multiplier = Double.parseDouble(multiplierNumber);
// ensure we have a legal column index
if (columnIndex < 0 || columnIndex >= indata[0].length) {
return outdata;
}
for (int row=0; row < indata.length; row++) {
// for each row
for (int col=0; col < indata[0].length; col++) {
// for each column
// get the existing column index
Object val = indata[row][col];
// copy the original data
outdata[row][col] = val;
if (col == columnIndex) {
// this is the column we want to multiply
double dv = 1;
if (val instanceof Number) {
// the data object is a number
dv = ((Number)val).doubleValue();
} else {
// attempt to convert the data object to a number
try {
dv = Double.parseDouble(val.toString());
} catch (Exception ex){
// non-numeric value; ignore and continue
continue;
}
}
// multiply the number and write to the output
outdata[row][newColIndex] = new Double(dv*multiplier);
}
}
}
} catch (Exception ex) {
// something failed – report the error and return the original input data
ex.printStackTrace();
return indata;
}
if (hasColumnNames) {
outdata[0][newColIndex] = “Multiplied”;
}
// return the output
return outdata;
Writing the Process Module GUI
The next step is to write the Process Module GUI. This file will be used to dynamically create a dialog that solicits input data from the user.
Create a text file called DataMultiplyInfo.java. Edit the file and enter the following:
package com.visualmining.example.processmodules;
import java.util.Hashtable;
import netcharts.server.api.NDSPostProcessorInterfaceInfoV2;
import netcharts.server.api.NDSPostProcessorInterfaceParameterInfo;
import netcharts.server.api.NDSPostProcessorInterfaceParameterValidator;
public class DataMultiplyInfo implements NDSPostProcessorInterfaceInfoV2 {
The getName() method returns the name of the Process Module as seen by the user, and thegetDescription() method contains the detailed description. The getIsIndexed() method refers to whether or not this Process Module can be called multiple times within the same process chain
public String getName() {
return “Data Multiply”;
}
public String getDescription() {
return “Multiplies a column by the given value.”;
}
public boolean getIsIndexed() {
return true;
}
The getCategory() and getSubCategory() methods are used if the developers wishes to group multiple Process Modules together in the GUI’s Process Module list.
public String getCategory(){
return null;
}
public String getSubCategory(){
return null;
}
The getParameters() method returns an array of NDSPostProcessInterfaceParameterInfo objects. This particular Process Module returns three (3) such objects, one for the multiply column index, one for the multiplier, and one for the enable flag.
public NDSPostProcessorInterfaceParameterInfo[] getParameters() {
NDSPostProcessorInterfaceParameterInfo[] n = new NDSPostProcessorInterfaceParameterInfo[3];
n[0] = new NDSPostProcessorInterfaceParameterInfo() {
The getType() method can be one of NDSPostProcessorInterfaceParameterInfo.TEXT orNDSPostProcessorInterfaceParameterInfo.OPTION. The TEXT type indicates a text field should be shown. An OPTION type indicates a dropdown menu should be used (and the getOptionValues()method should be implemented).
public int getType() {
return NDSPostProcessorInterfaceParameterInfo.TEXT;
}
The getParameter() method returns the parameter name that the Process Module will look in the hashtable. The getDescription() method describes this parameter, and the getDefaultValue() method provides the default value to populate the control.
public String getParameter() {
return “dataMultiplyColumnIndex”;
}
public String getDescription() {
return “Specifies the column index (starting at zero) to multiply with.”;
}
public String getDefaultValue() {
return “0”;
}
public String[] getOptionValues() {
return null;
}
The getValidator() method returns a NDSPostProcessorInterfaceParameterValidator object. This provides the developer with control over the input from the end user. Data types may be checked and the field may be disabled.
public NDSPostProcessorInterfaceParameterValidator getValidator() {
return new NDSPostProcessorInterfaceParameterValidator() {
public boolean validate(String currentValue, Hashtable otherValues) {
return (currentValue.length() > 0);
}
public boolean enable(String currentValue, Hashtable otherValues) {
return true;
}
};
}
public boolean removeParameterIfEmpty() {
return false;
}
The getDisplayName() method returns the name of the parameter as shown to the end user.
public String getDisplayName() {
return “Multiply Target Column”;
}
};
n[1] = new NDSPostProcessorInterfaceParameterInfo() {
public int getType() {
return NDSPostProcessorInterfaceParameterInfo.TEXT;
}
public String getParameter() {
return “dataMultiplyMultiplier”;
}
public String getDescription() {
return “The value to multiply the Multiply Target Column with.”;
}
public String getDefaultValue() {
return “0”;
}
public String[] getOptionValues() {
return null;
}
public NDSPostProcessorInterfaceParameterValidator getValidator() {
return new NDSPostProcessorInterfaceParameterValidator() {
public boolean validate(String currentValue, Hashtable otherValues) {
return (currentValue.length() > 0);
}
public boolean enable(String currentValue, Hashtable otherValues) {
return true;
}
};
}
public boolean removeParameterIfEmpty() {
return false;
}
public String getDisplayName() {
return “Multiplier”;
}
};
n[2] = new NDSPostProcessorInterfaceParameterInfo() {
public int getType() {
return NDSPostProcessorInterfaceParameterInfo.OPTION;
}
public String getParameter() {
return “dataMultiplyEnable”;
}
public String getDescription() {
return “Enable/Disable multiply function. Useful during development.”;
}
public String getDefaultValue() {
return null;
}
public String[] getOptionValues() {
return new String[] {String.valueOf(true),
String.valueOf(false)};
}
public NDSPostProcessorInterfaceParameterValidator getValidator() {
return new NDSPostProcessorInterfaceParameterValidator() {
public boolean validate(String currentValue, Hashtable otherValues) {
return true;
}
public boolean enable(String currentValue, Hashtable otherValues) {
return true;
}
};
}
public boolean removeParameterIfEmpty() {
return true;
}
public String getDisplayName() {
return “Enable Multiply Function”;
}
};
return n;
}
/* (non-Javadoc)
* @see netcharts.server.api.NDSPostProcessorInterfaceInfo#getAdditionalParameters()
*/
public Hashtable getAdditionalParameters() {
return null;
}
}
To compile the DataMultiply.java and DataMultiplyInfo.java file and store them in a JAR file for use in NetCharts Server and NetCharts Designer, type makejar at the command prompt. Provided there are no typographical errors, the ExampleProcessModules.jar should be built in the development directory.
Deploy the Process Module to NetCharts Designer and Test
During this part of the example, we will load our new ExampleProcessModules.jar file into NetCharts Designer for use.
- As described earlier in this document, Process Modules are deployed and registered in NetCharts Designer by selecting the right mouse button over the Designer Navigator window and then selecting “NetCharts Designer->Import Process Modules…”.When the Import Process Modules dialog appears, use the Select… button to browse to your development directory, and select the ExampleProcessModules.jar file. Select Open on the file browser,
and Finish on the Import Process Modules dialog. If there are no errors, a dialog should appear informing you that the import was successful and that you should restart.
- Restart NetCharts Designer.
- Create a new project called PMTest
- Create a new Named Data Set called data. Use the Hypersonic SQL Data Source.
- Type
select * from pagehittable
into the SQL text area and select Finish.
- Select the Functions tab at the bottom of the Named Data Set editor panel.
- In the Process Modules group on the right side of the panel, select the Add button, and then select Data Multiply in the list.
- Select OK. This will cause the dialog (generated from the Info class) to appear. We will multiply the last column of the data set. Column indexes start at 0, so enter 3 into the Multiply Target Column field. Set the Multiplier field to 10.
- Select Finish. An additional column is added showing the results of the last column being multiplied by 10.
- Finally, prepare the project for deployment to NetCharts Server. Select Export Project Archive… from the Navigator window’s right click menu and export the project.
Deploy the Process Module to NetCharts Server and Test
- Go to the NetCharts Server’s Admin Console and login (the default login/password is “Admin”).
- Select Import JAR Files from the Utilities section on the left panel and select theExampleProcessModule.jar file from your development directory.
- Select the Upload button. When completed, click the link to restart NetCharts Server.
- Next, select Project Archive from the Utilities section on the left panel. Click on the Uploadbutton and browse to the location of the PMTest archive (created in the last step of the NetCharts Designer section above).
- Follow the instructions to import the project.
- Once completed the data, with the Process Module applied, should be visible by using the URL as shown: (replace localhost with other server name if necessary) http://localhost:8001/projects/PMTest/data.ndx
Best Practices
The following are some suggested guidelines for good development of Process Modules.
Documentation
The more details you can provide in the general description and individual parameter descriptions, the more likely that users will be able to understand and use your Process Module.
Parameter Validation
The NDSPostProcessorInterfaceParameterValidator should be used to check the accuracy of the input parameters.
Debug Information
The NFDebug.PROCESSMODULE interface (as demonstrated in the example) can be used to write out informative messages to help people understand and resolve problems.
Enable/Disable Feature
Give your users the ability to turn off the Process Module’s functionality (as demonstrated in the example) without having to delete it and reenter the configuration data again.
Naming Conventions
Make sure your parameter names are unique. If they are not, your Process Module may use parameter settings that are intended for other Process Modules. At Visual Mining, we use the name of the Process Module as the prefix to the parameter, for example, dataMultiplyMultiplier. Also, insure that the Java class and package name is unique. At Visual Mining, we use package names in the form com.visualmining.packagename.
Example 1 – DataMultiply.java
package com.visualmining.example.processmodules;
import java.util.Hashtable;
import netcharts.util.NFDebug;
import netcharts.server.api.NDSPostProcessorInterface;
public class DataMultiply implements NDSPostProcessorInterface
{
public Object[][] processNDS(Object indata[][], Hashtable params, int nth){
if (indata == null || indata.length < 1) return indata;
// create an output structure the same size as the input plus the output column.
Object outdata[][] = new Object[indata.length][indata[0].length+1];
int newColIndex = indata[0].length;
int columnIndex = 0;
double multiplier = 1.0;
boolean hasColumnNames = false;
try {
// Check to see if the original data set has column names. If so we’ll
// need to insert a column name
String includeColNames = (String)params.get(“includeColumnNames”);
hasColumnNames = (includeColNames != null && includeColNames.equalsIgnoreCase(“true”));
// check for the parameter “dataMultiplyEnable”. This will allow the user
// to disable/enable this function if desired.
String enabled= (String)params.get(“dataMultiplyEnable”+nth);
if (enabled != null && enabled.equalsIgnoreCase(“false”))
return indata;
// get the index of the column and the multiplier parameters from
// the NDS parameter hashtable.
String indexString = (String)params.get(“dataMultiplyColumnIndex”+nth);
String multiplierNumber = (String) params.get(“dataMultiplyMultiplier”+nth);
// convert the parameters into their numerical equivalents
columnIndex = Integer.parseInt(indexString);
multiplier = Double.parseDouble(multiplierNumber);
// write a debug statement
NFDebug.print(NFDebug.PROCESSMODULE,”DataMultiply: multiplyColumnIndex set to “+indexString);
// ensure we have a legal column index
if (columnIndex < 0 || columnIndex >= indata[0].length)
return outdata;
for (int row=0; row < indata.length; row++){
// for each row
for (int col=0; col < indata[0].length; col++){
// for each column
// get the existing column index
Object val = indata[row][col];
// copy the original data
outdata[row][col] = val;
if (col == columnIndex){
// this is the column we want to multiply
double dv = 1;
if (val instanceof Number){
// the data object is a number
dv = ((Number)val).doubleValue();
} else {
// attempt to convert the data object to a number
try {
dv = Double.parseDouble(val.toString());
} catch (Exception ex){
// non-numeric value; ignore and continue
continue;
}
}
// multiply the number and write to the output
outdata[row][newColIndex] = new Double(dv*multiplier);
}
}
}
} catch (Exception ex){
// something failed – return the original input data
ex.printStackTrace();
return indata;
}
if (hasColumnNames)
outdata[0][newColIndex] = “Multiplied”;
// return the output
return outdata;
}
}
Example 2 – DataMultiplyInfo.java
package com.visualmining.example.processmodules;
import java.util.Hashtable;
import netcharts.server.api.NDSPostProcessorInterfaceInfoV2;
import netcharts.server.api.NDSPostProcessorInterfaceParameterInfo;
import netcharts.server.api.NDSPostProcessorInterfaceParameterValidator;
public class DataMultiplyInfo implements NDSPostProcessorInterfaceInfoV2 {
public String getName() {
return “Data Multiply”;
}
public String getDescription() {
return “Multiplies a column by the given value.”;
}
public boolean getIsIndexed() {
return true;
}
public String getCategory(){
return null;
}
public String getSubCategory(){
return null;
}
public NDSPostProcessorInterfaceParameterInfo[] getParameters() {
NDSPostProcessorInterfaceParameterInfo[] n = new NDSPostProcessorInterfaceParameterInfo[3];
n[0] = new NDSPostProcessorInterfaceParameterInfo() {
public int getType() {
return NDSPostProcessorInterfaceParameterInfo.TEXT;
}
public String getParameter() {
return “dataMultiplyColumnIndex”;
}
public String getDescription() {
return “Specifies the column index (starting at zero) to multiply with.”;
}
public String getDefaultValue() {
return “0”;
}
public String[] getOptionValues() {
return null;
}
public NDSPostProcessorInterfaceParameterValidator getValidator() {
return new NDSPostProcessorInterfaceParameterValidator() {
public boolean validate(String currentValue, Hashtable otherValues) {
return (currentValue.length() > 0);
}
public boolean enable(String currentValue, Hashtable otherValues) {
return true;
}
};
}
public boolean removeParameterIfEmpty() {
return false;
}
public String getDisplayName() {
return “Multiply Target Column”;
}
};
n[1] = new NDSPostProcessorInterfaceParameterInfo() {
public int getType() {
return NDSPostProcessorInterfaceParameterInfo.TEXT;
}
public String getParameter() {
return “dataMultiplyMultiplier”;
}
public String getDescription() {
return “The value to multiply the Multiply Target Column with.”;
}
public String getDefaultValue() {
return “0”;
}
public String[] getOptionValues() {
return null;
}
public NDSPostProcessorInterfaceParameterValidator getValidator() {
return new NDSPostProcessorInterfaceParameterValidator() {
public boolean validate(String currentValue, Hashtable otherValues) {
return (currentValue.length() > 0);
}
public boolean enable(String currentValue, Hashtable otherValues) {
return true;
}
};
}
public boolean removeParameterIfEmpty() {
return false;
}
public String getDisplayName() {
return “Multiplier”;
}
};
n[2] = new NDSPostProcessorInterfaceParameterInfo() {
public int getType() {
return NDSPostProcessorInterfaceParameterInfo.OPTION;
}
public String getParameter() {
return “dataMultiplyEnable”;
}
public String getDescription() {
return “Enable/Disable multiply function. Useful during development.”;
}
public String getDefaultValue() {
return null;
}
public String[] getOptionValues() {
return new String[] {String.valueOf(true),
String.valueOf(false)};
}
public NDSPostProcessorInterfaceParameterValidator getValidator() {
return new NDSPostProcessorInterfaceParameterValidator() {
public boolean validate(String currentValue, Hashtable otherValues) {
return true;
}
public boolean enable(String currentValue, Hashtable otherValues) {
return true;
}
};
}
public boolean removeParameterIfEmpty() {
return true;
}
public String getDisplayName() {
return “Enable Multiply Function”;
}
};
return n;
}
/* (non-Javadoc)
* @see netcharts.server.api.NDSPostProcessorInterfaceInfo#getAdditionalParameters()
*/
public Hashtable getAdditionalParameters() {
return null;
}
}
Where can I go for additional resources and help?
In addition to the online help file there are three additional places where you can obtain assistance:
- Visual Mining Customer Support Portal: Here you will find FAQS, tips and tricks and links to other resources that will help you create dashboards.
- Your Visual Mining Account Representative – send them an email, or call them. In case you’re not sure who your account rep is, send an email to sales@visualmining.com.
- Send us a question via Visual Mining support: support@visualmining.com or Phone 1.301.795.2200, or Toll-Free within the continental US: 800.308.0731