MP

Hi,

I have to update an existing matrix model by script, reading from an excel file.

I found this kind of problems:

  1. matrix.ConnectionData.isFromRowToCol ( ) doesn't work: the result is always null.
  2. matrix.createHeaderCell ( MatrixHeaderCell cellToInsertBefore, ObjDef objDef, int symbol, int size, boolean rowHeader ) doesn't work: the result is always: Wrapped java.lang.nullPointException.
  3. 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);
        }

    }
    
}

 



 

 

by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Fri, 10/23/2015 - 11:50

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

 

0
by Jean-Philippe Legoupil
Posted on Fri, 08/19/2016 - 11:38

Hello,

I have the same problem : I want to update matrix model by script and it doesn't work...

The non working function is : matrix.createHeaderCell ( MatrixHeaderCell cellToInsertBefore, ObjDef objDef, int symbol, int size, boolean rowHeader )

See script code below :

function MiseAJourMatrice(tabObj_objLigne, tabObj_Colonne, matrice, numSymb_Ligne, numSymb_Colonne){

    var matrice = matrice.getMatrixModel();

   

//Récupère les entêtes (en ligne et en colonne) de la matrice

    var rowHeader    = matrice.getHeader(true);

    var columnHeader = matrice.getHeader(false);

    var rowCells = rowHeader.getCells();

    var columnCells = columnHeader.getCells();

       

    for (cptligne = 0; cptligne < tabObj_objLigne.length; cptligne++)

    {

        var result = new Array();

        result = getMatrixHeaderCellByObjDef(tabObj_objLigne[cptligne],matrice,true);

        if(result[0] == 1)

        {

//            matrice.deleteHeaderCell(result[1]); // deleteHeaderCell correctly works, if matriching ObjDef founded, the row is deleted

//  only for testing and debugging

        } else

        {// If Object not founded, a new row in the HeaderCell should be created but it doesn't works

            var cellLigne = matrice.createHeaderCell( null , tabObj_objLigne[cptligne], -1, -1, true);

        }

    }

 

    for(var cptcol = 0; cptcol < tabObj_Colonne.length; cptcol++)

    {

        var result = new Array();

        result = getMatrixHeaderCellByObjDef(tabObj_Colonne[cptcol],matrice,false);

        if(result[0] == 1)

        {

//            matrice.deleteHeaderCell(result[1]);

// only for debugging, deleteHeaderCell correctly works, if Object if founded, the column is deleted

        } else

        {

            var CellCol = matrice.createHeaderCell( null , tabObj_Colonne[cptcol], -1 , -1, false);

            var toto = "stop"; // Break point for checking variables during debug

        }

    }

    return matrice;

}

 

function getMatrixHeaderCellByObjDef(objDef,matrice,isRow){

    var result = new Array();

    result[0] = 0;

    matrice = matrice.getMatrixModel();

    var header = matrice.getHeader(isRow);

    var headerCells = new Array();            

    headerCells = header.getCells();

    for(var i = 0; i < headerCells.length; i++)

    {

        if (headerCells[i].getDefinition().IsEqual(objDef))

        {

            result[1] = headerCells[i];

            result[0]++;

            break;

        }

    }

   return result;

}

When I put a break point on bold line

CellCol : com.idsscheer.aris.server.bl.common.reportobjects.aris.logic.AMatrixHeaderCell@51252b39

CellCol.getDefinition() : Wrapped java.lang.NullPointerException

tabObj_Colonne[cptcol] : ObjDef ID=cut###22e###p##

I tried to change null parameter with an existing HedaerCell, -1 Symbol and -1 Size with Object Symbol or Column Size, the result is allways the same, it doesn't work...

Is there any bug known with ceateHeaderCell function

Can you help me ?

 

Thanks

JP LEGOUPIL

0

Featured achievement

Question Solver
Share your expertise and have your answer accepted as best reply.
Recent Unlocks
  • CP
  • BZ
  • Profile picture for user TEF_Bernd
  • ПЦ
  • CR
  • PacMan

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock