iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
593 stars 211 forks source link

Map ECInstanceIds from desktop sdk to Itwin #2846

Closed lmborione closed 2 years ago

lmborione commented 2 years ago

Hi,

We have a legacy database that contains information extracted from .i.dgn files using the i-model desktop sdk. In the databse ECInstanceIds are stored in following format:

:ECDB00000000:15D5270000

When we use the new Itwin platform ECInstanceId for the same object is stored like this:

0x2b0000079abf

How could we compute the Itwin ECInstanceId from the previous one ?

Thanks

ColinKerr commented 2 years ago

Hi @lmborione there is a WIP PR to add this information to our doc site. Please take a look at the PR, @jchick-bentley and I would love to get your feedback.

https://github.com/iTwin/itwinjs-core/pull/2735

lmborione commented 2 years ago

Thanks for your reply.

I don't understand how your reply is an answer to my question... You sent me a link to a PR of the documentation, was I supposed to find anything related to my question in the "provenance-in-imodel.md" section ?

Moreover, how do you access provenance information ? I try to run the following SQL request in the imodelconsole:

select * from bis.externalsource

But the return object does not contains a "Provenance" field

When it comes to get the provenance at an ECInstance at the object level not the model one, how do you proceed.

Does Itwin kept the i-model desktop sdk ECInstanceId somewhere in its database ?

Thanks.

ColinKerr commented 2 years ago

@lmborione this is good feedback. We need to add documentation that is more concrete and less conceptual. We are also not linking to other pertinent information in other areas of our doc site. We will do both of these things, some in the current PR and some in other PRs that I will link here.

In the short term here is a bit more info. The original id from dgn or other source file is stored in the ExternalSourceAspect.Identifier property. Here is our documentation for this class: https://www.itwinjs.org/bis/domains/biscore.ecschema/#externalsourceaspect

Here is a simple query that will select an element and the identifier:

SELECT e.ECInstanceId, e.UserLabel, e.CodeValue, esa.Identifier FROM bis.Element e JOIN bis.ExternalSourceAspect esa ON e.ECInstanceId = esa.Element.Id 

If you are willing we would love your continued feedback.

lmborione commented 2 years ago

Ok thanks for the more detailled answer. In result I will implement a link base on identifier+schema+class to match to an ecInstance in my database