‎12-06-2012 09:30 PM
There was another post that asked about the Excel tool, but i'd like to ask it again, but a little differently.
I use the Excel tool to export and import mass changes from/to Mega, and it works well for attributes on a single MetaClass.
However, I also have the need to export and import various MetaAssocations between two MetaClasses. Does anyone have a mechanism for doing this? Before I go off and write a script to do this, I wanted to find out how others are doing this. This would save us countless hours writing specialized import scripts or manually making connections.
Yes, I have tried matrices, but they do not preserve the _HexaIDAbs and use Short Name, which makes the import difficult.
My idea for doing this is to write an Excel script that is combination of the Excel tool and Matrices:
1) Manually put the _HexaIDAbs property of the MetaAssociation in cell A1. The script could prompt for the MetaAssociation.
-- The rest of the steps could be handled by the script for all objects or a query to select the objects. --
2) In A3:An, put the long name of objects on one end of the MetaAssociation.
3) In B3:Bn, put the objects' _HexaIDAbs property
4) In C1:xx1, put long name of objects on the other end of the MetaAssociation.
5) In C2:xx2, put the objects' _HexaIDAbs property
6) in each intersecting cell, put an 'X' if the MetaAssociation exists. On Export, it would value it from the respository. On Import, it would disconnect the blanks and connect the X's. Alternately, like in Matrices, the script could prompt for a MetaAttribute to put in the cell instead and store the _HexAIDAbs in B2.
This Excel sheet could be exported from Mega, modified,and imported later.
Thoughts?
Solved! Go to Solution.
‎19-06-2012 03:20 PM
Of course importing MEGA objects via MGR and MGL files are the ideal, but sometimes we don't have MEGA obejcts and links to start with.
Personalized Excel import tools that allow importing links are helpful when the links are coming from another tool (database tables exported to Excel) or are manual and we want to create or modify a large number.
The most common approach used on the field is to have our VB code in an Excel spreadsheet (not forgetting to reference the MEGA Application Automation Components library : mg_mapp.dll). The code is done in a generalizeable way such that the import sheet will work with any MEGA object type. This can be used in creation or update mode, but to be sure we are on the correct object, we require the long name of the existing object for any updates. As the long name is unique for any object type, we can be reassured that the correct object is being manipulated.
- The first row allows to configure the sheet.
. In the first column of the first row we put the name of the main MetaClass we want to manipulate (create or modify)
. In each cell of the following columns of the first row we put the name of a MetaAttribute or MetaAssociationEnd.
- The following rows contain the data, attribute values or the name of a connected object for a link.
The code works as follows :
1/ read the first row to establish what object, properties and links we are dealing with.
2/ treat each following row to create / modify MEGA objects
Use GetSelections to establish if an object already exists. If so, we can situate ourselves on that correct object to perform a SetProp or a GetCollection("...").Add. If not, we can proceed to the creation step.
Hope this helps !
‎13-06-2012 09:29 AM
Hello Blucas
First, welcome to the community
To transfer metamodel extensions or template, the standard .MGR export feature of MEGA is much more appropriate thant the Excel editor.
By design, this exports uses a 'propagation' mode that captures dependant objects like MetaAssociationEnds for a MetaAssociation.
Procedure to transfer a MetaAssociation X
In a transaction open in the source environment
- Select the MetaAssociation
- R click > Manage > Export
The window 'Export MEGA object' is displayed
The MetaAssociation X is added by default in the scope of objects to be export but you can add other objects
- Change the target file if necessary
- Click Export
A file X.MGR file is generated
To import the file X.MGR in the target environment, use the standard import feature of the MEGA Administration Console (Administration.exe)
Menu File > Import > MEGA File
As this is metamodel, you will have to compile the environment afterwards