Profile picture for user MWZ

Now we want to import an xml file into ARIS and generate new models. Therefore we presume the same notation of the xml file as generated above.

First we need a browse dialog so that the user can select the xml file he wants to import:

function getImportFile() {
    var sdefname = "";
    var sdefext = "*.xml!!xml file|*.xml||";
    var sdefdir = "";
    var stitle = "Import xml file";

    var aFiles = Dialogs.getFilePath(sdefname, sdefext, sdefdir, stitle, 0);    // Displays a file selection dialog on the client and makes the content of the selected files available in the report
    if (aFiles != null && aFiles.length > 0) {
        return aFiles[0];
    }
    return null;
}

The return value is an object of type “SelectedFile”. So we use method “getData” to get the content of the file and put it as input for the xml parsing method:

var importFile = getImportFile();
if (importFile != null) {
    var xmlData = importFile.getData();             // Content of the file
    var xmlReader = Context.getXMLParser(xmlData);  // Parses the specified XML file and returns an object that provides access to the XML document.
    if (xmlReader.isValid()) {
        var xmlRoot = xmlReader.getRootElement();   // Root element of the XML document

Next step is to read the model elements from the root object and create models in ARIS:

 var xmlModels = xmlRoot.getChildren("Model");
     var iterModel = xmlModels.iterator()
     while(iterModel.hasNext()) {
        var xmlModel = iterModel.next();
        // Create model
        var oModel = createModel(xmlModel, oGroup);
        if (oModel != null) {

Based on these models we read the objects and the connections and create the corresponding objects/connections in ARIS:

 var xmlObjs = xmlModel.getChildren("ObjDef");
        var iterObj = xmlObjs.iterator()
        while(iterObj.hasNext()) {
            var xmlObj = iterObj.next();
            // Create object definition and occurence
            createObject(xmlObj, oGroup, oModel);
        }

        var xmlCxns = xmlModel.getChildren("CxnDef");
        var iterCxn = xmlCxns.iterator()
        while(iterCxn.hasNext()) {
            var xmlCxn = iterCxn.next();
            // Create cxn definition and occurence
            createCxn(xmlCxn, oModel);
        }

During generation of the model we place all objects an connections with default values in the model so we had to layout the model after generating. We can do this by using the method “doLayout”.

At least, we open the model in the in the modeling window after running the report.

oModel.doLayout();                  // Executes a layout of the model
       oModel.openModel()                  // Opens the model in the modeling window after running the report

Function to create models:

function createModel(xmlModel, oGroup) {
    var sName = xmlModel.getAttribute("Name").getValue();
    var nTypeNum = parseInt(xmlModel.getAttribute("TypeNum").getValue());
    var sID = xmlModel.getAttribute("ID").getValue();

    var oModel = oGroup.CreateModel(nTypeNum, sName, g_nLoc);   // Creates a new model in the current group
    if (oModel.IsValid()) {                                     // Tests the validity of the object
        setAttrID(oModel, sID);                                 // Write attribute 'Identifier'
        return oModel;
    }
    return null;
}

To write the attribute “Identifier” we use this function:

function setAttrID(oItem, sID) {
    return oItem.Attribute(Constants.AT_ID, g_nLoc).setValue(sID);
}

Function to create object definitions and occurrences:

function createObject(xmlObj, oGroup, oModel) {
    var sName = xmlObj.getAttribute("Name").getValue();
    var nTypeNum = parseInt(xmlObj.getAttribute("TypeNum").getValue());
    var sID = xmlObj.getAttribute("ID").getValue();

    var oObjDef = oGroup.CreateObjDef(nTypeNum, sName, g_nLoc); // Creates a new m object definition in the current group
    if (oObjDef.IsValid()) {                                    // Tests the validity of the object
        setAttrID(oObjDef, sID);                                // Write attribute 'Identifier'

        var nSymbol = getSymbol(oModel, oObjDef);
        if (nSymbol > 0) {
            var oObjOcc = oModel.createObjOcc(nSymbol, oObjDef, 0, 0, true);    // Creates a new object occurrence of the specified object definition in the model
            if (oObjOcc.IsValid()) {                            // Tests the validity of the object
                return oObjOcc;
            }
            return null;
        }
    }
    return null;

    
    function getSymbol(oModel, oObjDef) {
        var aSymbols = ArisData.ActiveFilter().Symbols(oModel.TypeNum(), oObjDef.TypeNum());    // Returns a list of permitted symbols of the specified object type in the specified model type
        if (aSymbols.length > 0) {
            return aSymbols[0];
        }
        return 0;
    }
}

Function to create connection definitions and occurrences:

function createCxn(xmlCxn, oModel) {
    var sSourceName = xmlCxn.getAttribute("SourceName").getValue();
    var sTargetName = xmlCxn.getAttribute("TargetName").getValue();    
    var nTypeNum = parseInt(xmlCxn.getAttribute("TypeNum").getValue());
    var sID = xmlCxn.getAttribute("ID").getValue();

    var oSourceObjOcc = getObjectInModel(oModel, sSourceName);
    var oTargetObjOcc = getObjectInModel(oModel, sTargetName);
    
    if (oSourceObjOcc != null && oTargetObjOcc != null) {
        var oCxnOcc = oModel.CreateCxnOcc(oSourceObjOcc, oTargetObjOcc, nTypeNum, getDummyPointList()); // Creates a new relationship (definition and occurrence) between the specified object occurrences in the model
        if (oCxnOcc != null) {
            var oCxnDef = oCxnOcc.Cxn();
            setAttrID(oCxnDef, sID);                                // Write attribute 'Identifier'
        }
        return oCxnOcc;
    }
    return null;

    
    function getObjectInModel(oModel, sName) {
        var oObjOccsInModel = oModel.ObjOccList();                  // Returns all object occurrences in the model
        for (var i = 0; i < oObjOccsInModel.length; i++) {
            var oObjOcc = oObjOccsInModel[i];
            var oObjDef = oObjOcc.ObjDef();
            if (StrComp(oObjDef.Name(g_nLoc), sName) == 0) {        // Compare names
                return oObjOcc;
            }
        }
        return null;
    }    
    
    function getDummyPointList() {
        var pointList = new Array();
        pointList.push(new java.awt.Point(0, 0));
        pointList.push(new java.awt.Point(1, 1));        
        return pointList;
    }    
}

Here you can download the entire source code from the "XML Import" report.

Note: This article describe how to develop a report in ARIS. See this post for links to similar articles.

by abdelghani azri
Posted on Thu, 08/19/2010 - 02:35

Hello all,

I work on importation data from Excel to aris.

I write a script to parse an Excel file, but I have problem to read the sheets.

So can you help me?

Thanks.

0
by Fadi Darani
Posted on Thu, 11/25/2010 - 16:17

Hello Micheal ,

i try it but it did not work .

i can not creatmodel .

Thanks

0
by Linda Thomas
Posted on Wed, 02/02/2011 - 09:51

Hello Michael,
I am very new to ARIS.
As a part of my requirement i need to write a REPORT in ARIS that imports and XML file and stores the node values in a suitable format for creating DATA_TYPE_MODEL in ARIS.

can you please help m in reading this xml and extract the value of xml nodes and store it to some hash maps in ARIS.

Please help me with some inputs as i am totally stuck...
Regards,
Linda

0
by Linda Thomas
Posted on Wed, 02/02/2011 - 09:50

 

Hello Michael, I am very new to ARIS. As a part of my requirement i need to write a REPORT in ARIS that imports and XML file and stores the node values in a suitable format  for creating DATA_TYPE_MODEL in ARIS.   My XML is like below   <?xml version="1.0" encoding="utf-16" ?>  - <GDT>   <NODE_ID>0050569357F902DD9CE48D5F7D0FDD5F</NODE_ID>  - <GDT_ATTRIBUTES> - <UUID_KEY>   <UUID>00505693-57f9-02dd-9ce4-8d81547adee2</UUID>    </UUID_KEY> - <NAME_KEY>   <NAME>Amount</NAME>    </NAME_KEY>   <STRUCT_CAT>2</STRUCT_CAT>    <USAGE_CAT>2</USAGE_CAT>    <RESTRICTED_IND>false</RESTRICTED_IND>    </GDT_ATTRIBUTES> - <ALLOWED_QUALIFIERS> - <ITEM>   <NODE_ID>0050569357F902DD9CE48D5F85771D60</NODE_ID>    <NAME>Boundary</NAME>    <VERSION_ID>0000000000</VERSION_ID>    </ITEM> - <ITEM>   <NODE_ID>0050569357F902DD9CE48D5F8CA85D62</NODE_ID>    <NAME>Principal</NAME>    <VERSION_ID>0000000000</VERSION_ID>    </ITEM> - <ITEM>   <NODE_ID>0050569357F902DD9CE48D5F937F9D64</NODE_ID>    <NAME>Order</NAME>    <VERSION_ID>0000000000</VERSION_ID>    </ITEM> - <ITEM>   <NODE_ID>0050569357F902DD9CE48D5F9A5D1D66</NODE_ID>    <NAME>Due</NAME>    <VERSION_ID>0000000000</VERSION_ID>    </ITEM>  </ALLOWED_QUALIFIERS>   </GDT>   can you please help m in reading this xml and extract the value of xml nodes and store it to some hash maps in ARIS.   Please help me with some inputs as i am totally stuck... Regards, Linda  
0
by merrick meredith
Posted on Tue, 02/14/2012 - 14:26

Hello

Do you have the format of the xml file as used in the following script?

 

Thanks

merrick

0
by Romeo Paone
Posted on Thu, 10/24/2013 - 15:00

Dear Michael,

i hope this is the right page where i can post my question regarding the following issue.

I am trying to find the correct format to import the time attributes (static, orientation and processing time) from an excel file into my model in Aris.

The upload of the excel file worked for updating the values of  COST and FREQUENCY attributes.

For example,  a value of the time attirbute has the following format (0000:01:15:00) Constant, but adding the same format with different values on excel, it did not upload the change.

I have tried different format, but nothing seemed to work.

If anyone has a solution on this issue, it would be highly appreciated.

Thank you

Best Regards

Romeo 

0
by Romeo Paone
Posted on Fri, 11/15/2013 - 12:50

Hello again,

maybe i was not that clear.

I am finding problems in importing new values of  the attributes of TIME from an excel file to ARIS.

I cannot find the right format for making changes on the excel file and then importing the new values into ARIS.

 

For example:  format (0000:01:15:00) Constant, if i change this value ( hence same format), it is not imported into ARIS.

This issue is only for the TIME attribute, not for COST and FREQUENCY for example.

Any suggestions?

Thank you very much.

Romeo

0
by Gerard Torres
Posted on Sun, 01/25/2015 - 00:40

Hi,

I don't see oGroup defined anywhere. Would it be something like:

var groups = ArisData.getSelectedGroups();
for(var i = 0; i < groups.length; i++) {
    oGroup = groups[i];
    
    var importFile = getImportFile();
    if(importFile != null) {
        ...
    }
    ...
}

 

If not, where should I get the oGroup value?

Thanks

0
by RAFAEL ASSAYAG
Posted on Fri, 01/15/2016 - 21:53

What a shame!

I tried to read a very very simple XML file:

<?xml version="1.0" encoding="UTF-8"?>

<Root>

  <Model Name="Desdobrar estratégia">

    <ObjDef Name="Planejar força de trabalho" />

    <Model Name="Avaliar estratégia de recursos humanos">

      <ObjDef Name="Monitorar planejamento estratégico de recursos humanos" />

      <ObjDef Name="Gerenciar portfólio" />

    </Model>

    <ObjDef Name="Planejar custo de pessoal" />

    <Model Name="Definir estratégia de recursos humanos">

      <ObjDef Name="Realizar estudos" />

      <ObjDef Name="Estruturar projeto estratégico de recursos humanos" />

    </Model>

  </Model>

</Root>

But it seems not considering the hierarchy. When I apply the sequence

var xmlModels = xmlRoot.getChildren("Model");     var iterModel = xmlModels.iterator()     while(iterModel.hasNext())...   it considers all "Model" tags under "Root" despising the XML conventions about ends of nodes.     <Model Name="Desdobrar estratégia">

    <Model Name="Avaliar estratégia de recursos humanos">         .         .         ,     </Model>

  </Model>

  are treated as     <Model Name="Desdobrar estratégia"/>

  <Model Name="Avaliar estratégia de recursos humanos"/>     Is there someone who can help me?   Thanks in advance.
0
by RAFAEL ASSAYAG
Posted on Mon, 01/18/2016 - 19:16

In reply to by RAFAEL ESQUENA…

I suppose I've already "solved" the problem. In reality there's no problem. It was me not working the right way.

After some debugging code trials, I could evaluate clearly the behavior of the methods used.

Sorry!

Thanks to anyone who may be trying to discover what might be "wrong".

Rafael

 

0
by gowtham ramesh
Posted on Tue, 04/12/2016 - 16:04

Hi,

In code, comment says it creates object occurrence that means occurrence of already exiting object or it will be creating it for first time. Please help me understand. and also let me know what exactly object definition and object occurrence means so i can correct myself if I have misunderstood.

Thanks in advance.

Regards,

Gowtham R

0
by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Tue, 04/12/2016 - 17:09

You first have to create an object definition and then you can use this when creating an occurrence...

oObjDef = oGroup.createObjDef(...)

if (oObjDef.IsValid()){

    oObjOcc = oModel.createObjOcc(lSymbolNum, oObjDef, ...)

}

You always need an object definition for the occurences. When you put manually in Designer/Architect an object into a model, ARIS creates the needed object definition and places an occ for this def in the model.

Regards,

Robert

0
by Yuriy Stolyarov
Posted on Fri, 11/23/2018 - 09:57

Hello all!

I try to run this script, but it don't work.

ARIS complains on error in str

var oModel = oGroup.CreateModel(nTypeNum, sName, g_nLoc);   // Creates a new model in the current group

"TypeError: Cannot call method "CreateModel" of undefined"

Can you help me please?

 

0
by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Fri, 11/23/2018 - 11:01

Hi,

oGroup seems not to be defined...

BR Robert

0
by Yuriy Stolyarov
Posted on Wed, 01/23/2019 - 10:06
Hello.

For some reason, connections are not displayed under the current filter. If you enter the full filter when entering the database, then the connections are displayed.

Objects display the wrong icons - no matter what filter the xml-file was created (export) and under which filter the import was made.
0
by Gabriel Catão
Posted on Wed, 10/23/2019 - 20:20
Hello aris community.
I imported an xml from a template made in another aris server, but the information created in this template was blank
0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

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