Hi,
I have to update an existing matrix model by script, reading from an excel file.
I found this kind of problems:
- matrix.ConnectionData.isFromRowToCol ( ) doesn't work: the result is always null.
- matrix.createHeaderCell ( MatrixHeaderCell cellToInsertBefore, ObjDef objDef, int symbol, int size, boolean rowHeader ) doesn't work: the result is always: Wrapped java.lang.nullPointException.
- matrix.createCxn ( MatrixHeaderCell source, MatrixHeaderCell target, int cxnType ) doesn't work: the result is always: JavaException: java.lang.nullPointException.
The sample code is attached.
What is wrong? Can anyone help me?
Mary G. Pennarola
function updateMatrice(sheet)
{
var cellaGUID = sheet.getCell(1, 1);
if(iscellnull(cellaGUID))
return;
var p_model = __database.FindGUID(cellaGUID.getCellValue(), Constants.CID_MODEL);
if(p_model == null || p_model == undefined)
return;
var p_matrice = p_model.getMatrixModel();
var righe_matrice = p_matrice.getHeader(true).getCells();
var colonne_matrice = p_matrice.getHeader(false).getCells();;
var tipo_conn = p_matrice.getCxnData()[0];
var simboloRiga = tipo_conn.getSourceSymbolTypeNum();
var simboloColonna = tipo_conn.getTargetSymbolTypeNum();
var sizeRiga = righe_matrice[0].getSize();
var sizeColonna = colonne_matrice[0].getSize();
var direction = true;
//if(!tipo_conn.isFromRowToCol()) {
if(!direction) {
simboloRiga = tipo_conn.getTargetSymbolTypeNum();
simboloColonna = tipo_conn.getSourceSymbolTypeNum();
}
var last_riga = getLastIndex(sheet, 8, 0, 'r');
for(var r =8; r<last_riga; r++) {
var rowGUID = sheet.getCell(r, 0).getCellValue();
var colGUID = sheet.getCell(r, 2).getCellValue();
var p_findRiga = __database.FindGUID(rowGUID, Constants.CID_OBJDEF);
var p_findCol = __database.FindGUID(colGUID, Constants.CID_OBJDEF);
if(p_findRiga == null || p_findRiga == undefined || p_findCol == null || p_findCol == undefined)
continue;
var p_rowHeaderCell = getHeaderElement(p_findRiga, righe_matrice);
var p_colHeaderCell = getHeaderElement(p_findCol, colonne_matrice);
if(p_rowHeaderCell == null) {
p_rowHeaderCell = p_matrice.createHeaderCell(null, p_findRiga, simboloRiga, -1, true);
righe_matrice = p_matrice.getHeader(true);
}
if(p_colHeaderCell == null) {
p_colHeaderCell = p_matrice.createHeaderCell(null, p_findCol, simboloColonna, -1, false);
colonne_matrice = p_matrice.getHeader(false);
}
var test_content = null;
//if(tipo_conn.isFromRowToCol())
if(direction)
test_content = p_matrice.getContentCell (p_rowHeaderCell, p_colHeaderCell);
else
test_content = p_matrice.getContentCell ( p_colHeaderCell, p_rowHeaderCell);
if(test_content != null && test_content != undefined) {
var cnxs = test_content.getCxns();
if(cnxs != null && cnxs != undefined && cnxs.length>0)
continue;
}
var cxn_new = null;
try{
if(tipo_conn.isFromRowToCol())
cxn_new = p_matrice.createCxn( p_rowHeaderCell, p_colHeaderCell, 86);
else
cxn_new = p_matrice.createCxn( p_colHeaderCell, p_rowHeaderCell, 86);
}
catch(e) {
Dialogs.MsgBox(e);
}
}
}
Robert Goldenbaum on
Hi,
hm, I have a report in 7.2 that creates / updates a matrix model and it works fine. I have tried to find differences - perhaps some of the commands don't really work.
1) try to check "p_findRiga" also for invalid - perhaps the object could not be found
2) try createHeaderCell with a cell before (and not null)
3) try createHeaderCell with a cell width (instead of -1)
4) have you checked that simboloRiga contains a valid symbol num ?
BR Robert