how to use automate datalink to import data into existing template

3.43K viewsGeneral Discussion


I am using automatic datalink to load data from databse and able to load in new matrix.

1)I would like to know how to load the data obtained by JDBC into a existing model template by opening the model template and importng it into it.
a) Firs I want to open a model template
b) then wants to use the aumatic datalink to load it into existing template..
c)how to select the existing category in the template and import data into it

2) How to automate adding of category into filter tray as I import data from data base.

Although, QAPI is available but not much information is there about usablity of API. Also I referred the SimpleOALP example but could not get.

Please help me out.



Greetings Mack,

Below is a basic demonstration of an automated data import using QAPI.

public void testDataImport()
//getTemplatePath() returns the path to the templates folder on your machine
Model model = quantrix.openModel(getTemplatePath() + “”\Category.modelt””);

//The target matrix in the template model
MatrixView mv = model.getMatrixNamed(“”Category Matrix””);

//getJDBCData returns an IDataGrid that wraps your JDBC data source
IDataGrid data = getJDBCData();

//Set up the import properties to configure the import
Map importProperties = new HashMap();
Map[] columnProps = new Map[5];

importProperties.put(ImportMapKeys.cIsMultiDimensionalKey, Boolean.TRUE);
importProperties.put(ImportMapKeys.cFirstRowIsHeaderKey, Boolean.TRUE);
importProperties.put(ImportMapKeys.cTargetMatrixKey, mv.getName());
importProperties.put(ImportMapKeys.cColumnSettingsKey, columnProps);

columnProps[0] = new HashMap();
columnProps[0].put(ImportMapKeys.cColumnIsCategoryKey, Boolean.TRUE);
//Set the category that this column will rendezvous with
columnProps[0].put(ImportMapKeys.cColumnRendezvousCategoryKey, “”Period””);
columnProps[0].put(ImportMapKeys.cColumnSkippedKey, Boolean.FALSE);

columnProps[1] = new HashMap();
columnProps[1].put(ImportMapKeys.cColumnSkippedKey, Boolean.FALSE);
columnProps[1].put(ImportMapKeys.cColumnIsCategoryKey, Boolean.FALSE);

columnProps[2] = new HashMap();
columnProps[2].put(ImportMapKeys.cColumnIsCategoryKey, Boolean.FALSE);
columnProps[2].put(ImportMapKeys.cColumnSkippedKey, Boolean.FALSE);

columnProps[3] = new HashMap();
columnProps[3].put(ImportMapKeys.cColumnSkippedKey, Boolean.TRUE);
columnProps[4] = new HashMap();
columnProps[4].put(ImportMapKeys.cColumnSkippedKey, Boolean.TRUE);

//Perform the actual import
model.importData(data, importProperties);

//Move a category to the filter tray
Node category = mv.getCategory(“”Class””);
mv.setCategoryAxis(category, QuantrixConstants.cFilterAxis);
model.saveModelTo(“”C:\Temp\Imported Model.model””, true);

Here are several things to keep in mind.
1) When you open a template model, you must remember to save it to another file, otherwise you will end up modifying the template.
2) You have to know in advance the structure of your data, such as number of columns, so you can set up the import properties correctly.
3) There is a bug in the implementation so that you must specify the columns skipped key.
4) The IDataGrid interface is a simple interface that you can wrap around the JDBC connection. I leave the implementation of that to you.
5) Once the import is complete, you may move categories to the different axes.

I hope this helps. Feel free to ask for futher clarification.

Brian Cabana

You are viewing 1 out of 2 answers, click here to view all answers.