[BM SS4] What happens to User Data Linkages?

I've got a regular MicroStation drawing with shape elements that include a User Data Linkage that points back to an Oracle table. What happens to that linkage when I open that drawing in Map Enterprise, and use the "Promote" tools to convert that simple shape into a native feature residing in a SQL*Server database? Is it lost? Is there any way to "capture" that linkage? The MSLINK value is the record ID of the Oracle data that I would want to insert into the data columns of the SQL*Server spatial table. We've got many shapes, so I'm hoping there is some automated process that can be set up to "preserve" that linkage information so it can be used to ensure the right record from Oracle is associated with the right record in SQL*Server.

Thanks,

Bruce

Parents
  • Bruce,

    During the "Promote" process the database linkages should be preserved and remain available on the elements. However database linkage information is not automatically available on the feature instance or inserted into the spatial database during a post operation. The good news is that with a few lines of VBA code the polygon features can be located and database MSLINK values can be copied to a business property that when posted to the spatial database would "preserve" the Oracle association.

    database_links1.mvba

    Attached is the complete MVBA example but the key portions of the code are shown below. Please note that you will have to update the database linkage type, database entity number and XFM business property name for your spatial feature class to accommodate your specific needs.

    Perform Locate Operation (for file, fence or selection set processing of specific feature class(es))

    Private Sub performLocateOperation()
    
        Dim oLocateOp As New locateOp
        
        oLocateOp.ClearHilited = True
        oLocateOp.IncludeOnlyFeatures = True
        oLocateOp.IncludeFeatureName "MyPolygonFeature1"
        
        If ActiveDesignFile.Fence.IsDefined = True Then
            
            oLocateOp.Mode = LocateOpMode.locateOpModeFence
            oLocateOp.AutoAcceptFence = True
        
        ElseIf ActiveModelReference.AnyElementsSelected Then
            
            Dim selectionSetValue As New InputValue
            
            selectionSetValue.SetTypeAndValue ValueType_VALUE, "1"
            oLocateOp.UseSelectionSet = selectionSetValue
            oLocateOp.AutoAcceptSelectionSet = True
            oLocateOp.Mode = LocateOpMode.locateOpModeIdentify
        
        Else
            
            oLocateOp.Mode = LocateOpMode.locateOpModeScan
            oLocateOp.AutoAcceptScanFile = True
        
        End If
               
        CmdMgr.StartLocateOperation oLocateOp, New clsLocateFeatureOp
    
    End Sub

    Process Located Feature Instances (copy MSLINK value from database link to XFM business property)

                With fe.Current
                
                    If .GetFeatureDefinition.IsCollection Then
                        
                        Dim index As Long
                        
                        For index = 0 To (.SubFeatureCount - 1)
                            
                            Dim oSubFeature As feature
                            
                            Set oSubFeature = .GetSubFeature(index)
                            
                            With oSubFeature
                            
                                If .GeometryType = GEOMETRYTYPE_Polygon Then
                                    
                                    Dim databaseLinks() As databaseLink
                                    
                                    If .Geometry.IsGraphical Then
                                        
                                        databaseLinks = .Geometry.GetDatabaseLinks _
                                        (msdDatabaseLinkageOdbc, cDatabaseLinkEntitynum) mslinkValue = databaseLinks(0).Mslink End If End If End With Next End If .SetProperty cDatabaseLinkColumnName, Str(mslinkValue) .Write (False) End With

    Regards,

    Jeff Bielefeld [Bentley]



  • Awesome !! I can't wait to look at this and give it a try. If I understand correctly, one would first "Promote" the graphics to a feature (which inserts them into the spatial database) then run this modified example to read/extract the database linkage value (MSLINK in my case) and have it written to the desired database table column, thus preserving that data. Then it's a simple matter of SQL update statements to get the rest of the data loaded into the spatial table columns ....
  • Bruce,

    The provided MVBA example code demonstrates how one could read the MSLINK value from the graphical element in the promoted polygon collection feature instances and write the value to a business property, which after posting would appear in a column of your Microsoft SQL Server spatial database.

    There are several ways to approach this depending on your specific needs. For example you might do the following:

    1. Add "ORACLE_LINK" column to your Microsoft SQL Server database table.
    2. Perform "Register Features..." process in the Bentley Geospatial Administrator application to discover the new "ORACLE_LINK" column.
    3. Perform "Insert > Polygon Collection Placement Metadata..." and ensure that you have enabled the "Include Promote Method" option.
    4. Perform "Update Command Manager List" with the "Include Method Name in Labels" option enabled.
    5. "Save", "Export" and "Run" the workspace.
    6. In the "Command Manager" run the "MyPolygonCollection (Promote)" command.
    7. Follow prompts to promote your existing MicroStation shape elements to Bentley Map XFM polygon collection feature instances.
    8. After modifying the provided "database_links1.mvba" to suite your specific needs, run the "performLocateOperation" subroutine. This process will read the MSLINK value and use the "setProperty" method to write the MSLINK value on the local feature instance.
    9. Perform "Post" operation to insert the feature instances to your Microsoft SQL Server spatial database.
    10. In Microsoft SQL Server perform SQL update statements to load other data values from Oracle tables.

    Again, this is just one approach that leverages the Bentley Map API to help solve a data migration challenge.

    Regards,

    Jeff Bielefeld [Bentley]



  • I've had a change to play with the example, and it does what I need - but it isn't "consistent". Maybe I don't fully appreciate the way feature location works. I've "prompted" 6 shapes to features, then selected the 6 features and ran the example. I never get all 6 shapes (native features) populated with MSLINK values. And it's never the same ones that get updated. sometimes 2 or 3 get updates, other times 4 or 5. I print out the elementIDs of the elements that are passed through OnValidate() and I only ever see two elementIDs, yet like I said, sometimes I get 3 or 4 elements (features) updated......Maybe it's time to reboot and start fresh.

    Thanks for your help.
  • Bruce,

    Please zip up and send me via private message...

    1. Your modified MVBA file.
    2. A sample design file containing the original MicroStation shape elements.
    3. A current copy of your Bentley Geospatial Administrator schema file.

    ...and I will review.

    Regards,

    Jeff Bielefeld [Bentley]



  • I will gather the info as soon as I get a chance.

    I've been examining the "results" of the "Promote" tool (Feature is Polygon Collection). I begin with 5 elements selected (4 Complex Shape Inferred Features and 1 Grouped Hole inferred Feature), perform the "Promote" ( New element for each in selection set, do not remove original) and I'm ending up with 4 Inferred Complex Shape Features, 8 Complex Shape Native Features, 5 Polygon Collection Native Features and 1 Grouped Hole. The 8 Complex Shape Native Features must be the initial 5 complex shapes and the 3 "holes" associated with one of those shapes.

    I'm studying the OnValidate() event to try and see if I can correlate what elements are being passed in.
Reply
  • I will gather the info as soon as I get a chance.

    I've been examining the "results" of the "Promote" tool (Feature is Polygon Collection). I begin with 5 elements selected (4 Complex Shape Inferred Features and 1 Grouped Hole inferred Feature), perform the "Promote" ( New element for each in selection set, do not remove original) and I'm ending up with 4 Inferred Complex Shape Features, 8 Complex Shape Native Features, 5 Polygon Collection Native Features and 1 Grouped Hole. The 8 Complex Shape Native Features must be the initial 5 complex shapes and the 3 "holes" associated with one of those shapes.

    I'm studying the OnValidate() event to try and see if I can correlate what elements are being passed in.
Children
  • OK - I *think* I know what the issue is. My data includes "grouped holes" elements and when that top level element is queried for database links, none are returned (the result from Geometry.GataDatabaseLinks() is empty). Trying to extract a MSLINK from the non-existent database linkage was aborting the execution of the rest of the program. I added in a test to make sure a DatabaseLink array was returned, and things are much better. It seems the linkage I'm looking for is on the "Grouped Hole" element, and not any of the sub-parts, so there are no appropriate database linkages on the "sub-elements". Maybe there is a way to extract them from a Grouped Hole, but I'll have to study that some more.