Data Import Examples for Integration Tab

Post Reply
jaraujo
Posts: 4
Joined: 06 Sep 2010, 03:58

Greetings,

I understand the simple examples that come with the Integration tab, but I am unable to figure out how to import data that corresponds to slots beyond string types.

Can you pls provide an example or two that illustrates the syntax for importing Instances into a slot (one or more) as well as enumerations?

Thanks in advance.

Joe
User avatar
jonathan.carter
Posts: 1087
Joined: 04 Feb 2009, 15:44

Hi Joe,

Assuming that you're using the XSL approach to import from an XML data source, the transform that imports content from any Essential Repository XML covers all of these.
See the file: importEssentialInstances.xsl
I'm going to publish an updated version of this to the Share area tomorrow but this demonstrates how to use the Standard Functions (the Python functions library) to import instances that have slots of instance type, enumerations, etc.

Here is template that sets Instance (multiple and single cardinality) slots. Note the use of the addIfNotThere() function (from StandardFunctions), which handles the cardinality and prevents duplicate references to the same instance.

Code: Select all

    <!-- Send this template a set of one or more nodes of <own_slot_value> tags that have a value_type of simple_instance
        That is, a slot that is of type Instance Slot. Use a select statement such as: 
        select="pro:own_slot_value[pro:value/@value_type='simple_instance']" mode="InstanceSlot"
        from a simple instance node.
        This template then finds or creates the instances that need to be added to the specified slot.
        The template assumes that somewhere above, the 'standardFunctions.txt' Jython library will have been executed.
        Additionally, the template REQUIRES that you set a variable: 'theInstance' to the value of your new instance
        that contains these slot values.
    -->
    <xsl:template match="node()" mode="InstanceSlot">
        <!-- Take a node which is the entry for the instance attribute - this could have multiple values -->
        <!-- Get the slot that the instances will go in-->
        <xsl:text>aSlotName = "</xsl:text><xsl:value-of select="pro:slot_reference"></xsl:value-of><xsl:text>"</xsl:text>
        <xsl:text>&#xa;</xsl:text>
        <xsl:for-each select="pro:value">
            <xsl:text>anInstanceSlot = getEssentialInstanceContains("</xsl:text><xsl:apply-templates select="." mode="GetInstanceClass"></xsl:apply-templates><xsl:text>", "</xsl:text>
            <xsl:value-of select="."></xsl:value-of>
            <xsl:text>", "</xsl:text><xsl:value-of select="$ExternalRepository"></xsl:value-of><xsl:text>", "</xsl:text>
            <xsl:apply-templates select="." mode="GetInstanceName"></xsl:apply-templates>
            <xsl:text>")&#xa;</xsl:text>
          
            <!-- Handle multi/single cardinality instance slots -->
            <xsl:text>addIfNotThere(theInstance, aSlotName, anInstanceSlot)</xsl:text>
            <xsl:text>&#xa;</xsl:text>
        </xsl:for-each>
    </xsl:template>
I've recently had some trouble with Boolean and Floats in the 'importEssentialInstances.xsl' file, hence the new update.

When you say enumerations do you mean things that go into a Symbol type slot in Protege or do you mean our Utility super class Enumerations?
Symbols are actually dealt with in Protege as Strings - it's just that Protege restricts the allowed values for the value String. However, for View and import purposes, where we are dealing with XML representations, the Symbol slots are set in the same way as String slots.
If, however, you mean the Enumeration Classes that we have defined in the EA_Support section of the Essential Meta Model, these are all simply Instances and slots that refer to them will be Instance-type slots.

Hope this helps - and look out for the updated 'importEssentialInstances.xsl' file. I'll post a notification when I've released it.

Let me know how you get on, or need further help.

Jonathan
Essential Project Team
jaraujo
Posts: 4
Joined: 06 Sep 2010, 03:58

Perfect... Thank you.

As far as enumerations are concerned, yes, I was referring to Enumeration Classes that are part of the EA_Support section of the Essential Meta Model.

I will wait for your update and give it a shot.

Mucha appreciated.

Regards
User avatar
jonathan.carter
Posts: 1087
Joined: 04 Feb 2009, 15:44

Hi Joe.

I've released the updated 'importEssentialInstances.xsl' in the Share area.

There are some handy fixes in this update to handle strings that contain " characters (only becomes a problem in the generated integration scripts) and as I mentioned the Float and Boolean slots.

This updated version will be in the next release of the Integration Tab.

Keep me posted about how you are getting on

Jonathan
Essential Project Team
jaraujo
Posts: 4
Joined: 06 Sep 2010, 03:58

Jonathan,

Hello again. I have been making progress but once again I need some help. I have created some VBA code to take our technology repository and output it as XML in the Protege format (frames I believe).

For the most part, this is working well. However, I am running into issues when I have a lot of entries and each of the entries has some references. It appears I need to include the entries for all the references to other entries in the same xml file. Is this necessary? The files get quite large this way. I have tried to break up the file into smaller chunks (around 200K each), but I continue to get the following error..

javax.script.ScriptException: Traceback (innermost last):
(no code object) at line 0
SyntaxError: ('Lexical error at line 121, column 103. Encountered: "\\n" (10), after : ""', ('<unknown>', 121, 103, 'theInstance = getEssentialInstanceContains("Technology_Component", "CTC_Tech_Component_ID_Message Bus '))

I am using the Integration tab to load the xml file.

Any thoughts as to what I am doing wrong? Do I really need to include all the entries being referenced in the same xml file.
User avatar
jonathan.carter
Posts: 1087
Joined: 04 Feb 2009, 15:44

Hi,

To answer your first point, you only need to include the instances that you wish to import. So, your VBA can focus on creating the XML for those instances rather than on everything in your repository.

If you are producing XML that is in the format of the 'reportXML.xml' that is used by Essential Viewer, then you can use the 'importEssentialInstances.xsl' transform included with the Integration Tab to import your data.

Make sure to download the latest, updated version of 'importEssentialInstances.xsl' as there was a recent bug-fix release.

On the second point, about the size of the import file, this will be handled automatically by the Integration Tab, which will manage the 32KB script file limit of the underlying scripting engine.

Note, however that the getEssentialInstance() functions - there are a few variations that give you some choice with how instances are identified - manage any references to other instances for you. So, for example, you do not need to worry about the order in which instances are imported. These functions ensure that the correct instance is returned to you, and creates it if it is not already in your target repository.

From the error that you've posted, it looks like there are some formatting/syntax issues with the generated script, rather than a problem with what the code is doing.
Note, that getEssentialInstance() requires 4 parameters and you have only supplied 2 in the error report that you've posted.
For more information, see the tutorial documentation for getEssentialInstance() at the end of the article.

I think it would really help if you could post some examples of the XML file that your VBA is generating and any transform XSL files that you are using. If you are using the supplied, 'importEssentialInstances.xsl' transform, there's no need to post that - but do let me know.

Jonathan
Essential Project Team
jaraujo
Posts: 4
Joined: 06 Sep 2010, 03:58

Thanks Jonathan.

Yes, you are correct. I reviewed the data and did in fact have some CR characters embeddd in the data. Once I addressed these, all went well.

Much appreciated. I am getting closer. Thanks for your help.

Regards,
Joe
User avatar
jonathan.carter
Posts: 1087
Joined: 04 Feb 2009, 15:44

Great to hear that helped, Joe.

We're working on some more software to improve the integration process - but there is always going to be the issue of how to map your source data to the Essential meta classes.

Let me know how things go.

Jonathan
Essential Project Team
Post Reply