How to get the "Connection role" from a CxnOcc

Translate this pagebookmark or share this page
Marcus's picture

Posted: 2011-12-22
1357 views | 11 comments | category: Enterprise Architecture

0
show all articles

Hello,

 

I want to report the "Connection role" (AT_CXN_ROLE) from a connection.

function listOccsStrings(p_Output, p_ObjS, hm_DTbl, p_Array)
    {
        for(var i=0; i<p_Array.length; i++){
            p_Output.OutputLinkF( getAttrStrValue( p_Array[i].ObjDef(), Constants.AT_NAME, gn_Lang ), hm_DTbl.get("BMK"), getString("TEXT_STYLE_DEFAULT") );
            p_Output.OutputF( gs_Empty.concat(" (").concat( getCxnRole( p_ObjS, p_Array[i] ) ).concat(")"), getString("TEXT_STYLE_DEFAULT") );
            if( i<(p_Array.length - 1) ) { p_Output.OutputF( ", ", getString("TEXT_STYLE_DEFAULT") ); }
        }//END::for_i
        function getCxnRole( p_ObjS, p_ObjT){
            var aCxns   = p_ObjS.Cxns( CxnOccDirectionConstants.EDGES_IN, ReportConstants.EDGES_ALL);
            for(var j=0; j<aCxns.length; j++){
                if( ((aCxns[j].SourceObjOcc().equals(p_ObjS)) && (aCxns[j].TargetObjOcc().equals(p_ObjT))) ||
                    ((aCxns[j].SourceObjOcc().equals(p_ObjT)) && (aCxns[j].TargetObjOcc().equals(p_ObjS))) ){
 //Compare the right Source and Target object from connection
                    return aCxns[j].Attribute(Constants.AT_CXN_ROLE, gn_Lang).getValue();
//Doesnt work :(                
}
            }//END::for_j
            return gs_Empty;
        }//END::getCxnRole()
    }

This is an exapmle EPC:

My wish is to report like this:

 

Function                     Input

Funktion_1                Leistung1 (5)

Funktion_2                Leistung2 (2), Leistung3 (1)

 

Thanks a lot

Marcus Knappe

Comments
Vladimir's picture

Hi Marcus,

try this code

var oModel = ArisData.getSelectedModels()[0];
var oOccs = oModel.ObjOccListFilter(Constants.OT_FUNC);
var g_nLoc = Context.getSelectedLanguage();

oOccs = ArisData.sort(oOccs, Constants.SORT_Y, g_nLoc);
for (var o = 0; o < oOccs.length; o++){ 
    var oCxnOccs = oOccs[o].CxnOccList();
    for (var c = 0; c < oCxnOccs.length; c++){
      if (oCxnOccs[c].CxnDef().SourceObjDef().TypeNum() != Constants.OT_FUNC &&
          oCxnOccs[c].CxnDef().SourceObjDef().TypeNum() != Constants.OT_EVT &&
          oCxnOccs[c].CxnDef().TargetObjDef().TypeNum() != Constants.OT_EVT)  
        Dialogs.MsgBox(oOccs[o].ObjDef().Name(g_nLoc) + ' ' + oCxnOccs[c].CxnDef().SourceObjDef().Name(g_nLoc));
    }
}
Marcus's picture

Hi Vladimir,

 

it doesn't work :(

Function                  Input

Funktion_1             Leistung1 (Leistung1)

Funktion_2             Leistung2 (Leistung2), Leistung3 (Leistung3)

 

I want this:

Function                  Input

Funktion_1             Leistung1 (5)// Not the name from SourceObj, the "connection role" between Function and performance(is Input for) (5,2,1)

thanks

Vladimir's picture

Where are placed these numbers 5, 2, 1 - in connection "Identifier" attribute?

Marcus's picture

They were placed in connection "connection role" (AT_CXN_ROLE) attribute.

Not in "Identifier", because it's possible that two different performances have the same number to a function or a performance have the same number to two or more functions... The number isn't unique :)

Vladimir's picture

OK Marcus. I can read this atrribute:

Dialogs.MsgBox(oOccs[o].ObjDef().Name(g_nLoc) + 
'\n' + oCxnOccs[c].CxnDef().Attribute(Constants.AT_CXN_ROLE, g_nLoc).GetValue(true));
Vladimir's picture
   
Dialogs.MsgBox(oOccs[o].ObjDef().Name(g_nLoc) +
'\n' + oCxnOccs[c].CxnDef().Attribute(Constants.AT_CXN_ROLE, g_nLoc).GetValue(true));
Vladimir's picture

Sorry for double comment...I don't know delete comment...

Marcus's picture

Thank you Vladimir,

 

it works for me fine. One more Question is, is it possible, to get connections which are are not aktiv in this EPC and which are NOT aktive in an allocation diagrams like "Function allocation diagram" for the functions, but they are aktive in "Product trees".

EPC                                 Product tree      

     

 

Big thanks and a happy new year :)

 
 

 

Vladimir's picture

Hi Marcus,

try use OccList method for each function:

var oOccs2 = oOccs[o].ObjDef().OccList();
for (var o2 = 0; o2 < oOccs2.length; o2++){
    if (oOccs2[o2].Model().TypeNum() == Constants.MT_PRDCT_TREE){
       Dialogs.MsgBox("Function is in Product tree");
    }
}

Same to you Happy new year :)

Marcus's picture

It doesn't work :(

If I clean the EPC to normal EPC (only functions and events) then the connection role is lost :(

The products (Leistung 1-3) are shown correktly. If I copy one of the product back to EPC and connect it with its function, it works. But the big target ist normal EPCs and a product tree model.

I try it with a Function allocation diagram, but it doesn't work to :(

Vladimir's picture

Hi Marcus,

I'm sorry, but I can't help you now, because it works on my computer - all occurences are listed correctly.