Hello
I created a model matrix.
Created in it column headers and row headers from ObjDef objects (functions and roles) taken from the outFolder folder.
I placed the functions on rows, and placed the roles in columns.
Next, I'm trying to create connections between some functions and roles. Before creating the connection function, I check the contents of the row header and column header with MsgBox. But when calling the
"matrix.createCxn (aHeaderCol [0], aHeaderRow [0], Constants.CT_EXEC_2);"
method, a window with the
"Wrapped java.lang.NullPointerException"
error appears.
Tell me please what I'm doing wrong.
Here is the code:
function main() {
var db = ArisData.getActiveDatabase();
var group = ArisData.getSelectedGroups()[0];
var outFolder = db.Group(["Main_group", "Work folders", "Test", "Matrix", "output_1"], 1049);
var aFuncs = group.ObjDefListFilter ( 22 ); // Functions ObjDefs
var aRoles = group.ObjDefListFilter ( 78 ); // Roles ObjDefs
var oModel = outFolder.CreateModel(220,"Matrix_model",1049);
var matrix = oModel.getMatrixModel();
var Row_matrixHeader = matrix.getHeader(true);
var Column_matrixHeader = matrix.getHeader(false);
var Row_Header_Title = Row_matrixHeader.setTitle("Functions",1049);
var Column_Header_Title = Column_matrixHeader.setTitle("Roles",1049);
// Creating header row cells
for(var i=0; i < aFuncs.length; i++) {
matrix.createHeaderCell(null, aFuncs[i], Constants.ST_FUNC, -1, true);
matrix.setVisibleObjectSymbolTypes([Constants.ST_FUNC], true);
}
// Creating header column cells
for(var i=0; i < aRoles.length; i++) {
matrix.createHeaderCell(null, aRoles[i], Constants.ST_EMPL_TYPE, -1, false);
matrix.setVisibleObjectSymbolTypes([Constants.ST_EMPL_TYPE], false);
}
var aHeaderCol = Column_matrixHeader.getCells();
var aHeaderRow = Row_matrixHeader.getCells();
Dialogs.MsgBox("aHeaderCol[0]: " + aHeaderCol[0].getDefinition().Attribute(Constants.AT_NAME, 1049).getValue()); //OK
Dialogs.MsgBox("aHeaderRow[0]: " + aHeaderRow[0].getDefinition().Attribute(Constants.AT_NAME, 1049).getValue()); //OK
matrix.createCxn( aHeaderCol[0], aHeaderRow[0], Constants.CT_EXEC_2 ); // <- Error
}
main();
![Connection [0][0] planned, connection [1][1] not planned](/system/files/images/MatrixConnections.jpg)
Kay Fischbach on
Hi,
I was able to replicate this problem and as far as I can tell this is a bug in ARIS (the "wrapped" in the error message seemingly indicates that the nullpointer exception is happening in some deeper method, that we didn't write).
While it does throw the exception, as far as I can tell it still does what you want it to do - create the connection.
The connection isn't shown in your model, because you're missing two lines of code
You can execute those at any point after getting matrix from your freshly created model.
What those lines of code do is tell your model that you actually want connections of the type CT_EXEC_2 from ST_EMPL_TYPE to ST_FUNC in your matrix model to be indicated with a checkmark.
As for what to do with the matrix.createCxn(...) method that thows the exception...
A short term solution would be simply wrapping it with a try block which is followed by an empty catch block - this allows your program to continue the execution without horribly crashing and annoying the user with a cryptic message that doesn't even help you - the developer.
Long term solution would be contacting Software AG/ARIS support, explaining to them that the Matrix.createCxn(...) method consistently throws an exeption and hoping that they'll fix it in a future ARIS version/release a patch for the current ARIS version.
Sorry, this is probably a really unsatisfying answer for your problem, but I can't think of a better solution. I'm just a normal user and can't look any deeper into this.
Maybe someone else can find a better solution.