derrickoswald / CIMSpark

Spark access to Common Information Model (CIM) files
MIT License
15 stars 1 forks source link

Support denormalized models #11

Closed derrickoswald closed 7 years ago

derrickoswald commented 7 years ago

The CIM model is, by and large, well normalized. Apart from a few pathological cases, such as the relationship between Asset and PowerSystemResource which is many-to-many (a PowerSystemResource can have many associated Asset, and an Asset can have many associated PowerSystemResource), most relationships in CIM follow the normalized model where child objects contain a reference to the (haveA) parent object.

Despite this well defined normalization, delinquent programs, such as CIMdesk needlessly generate malformed CIM files where multiple elements are contained in the reverse relation of a simple one-to-many relationship.

Example 1

From the MicroGrid base case test configuration file MicroGridTestConfiguration_BC_BE_GL_V2.xml:

Location elements reference PowerSystemResource rather than vice versa

  <cim:Location rdf:ID="_4aa56f5f-d576-49e5-8aa0-95ef1ba262e3">
    <cim:Location.PowerSystemResources rdf:resource="#_37e14a0f-5e34-4647-a062-8bfd9305fa9d"/>
    <cim:Location.CoordinateSystem rdf:resource="#_6acd306f-43e5-4f69-93cb-53c048125cdf"/>
  </cim:Location>

Example 2

From the RealGrid test configuration file CGMES_v2.4.15_RealGridTestConfiguration_SV_v2.xml:

TopologicalIsland elements reference TopologicalNode rather than vice versa

<cim:TopologicalIsland rdf:ID="_TI-1">
        <cim:TopologicalIsland.TopologicalNodes rdf:resource="#_1841689480_VL_TN2"/>
        <cim:TopologicalIsland.TopologicalNodes rdf:resource="#_1113529077_VL_TN1"/>
        ...

The CIMReader has handled the many-to-many case, starting from fairly early versions, but extending this to handle badly formed CIM files will require:

Care should be taken so that performance is not severely degraded.

derrickoswald commented 7 years ago

Added CIMNormalize triggered by option ch.ninecode.cim.do_normalize=true. Created some small unit tests for the examples listed in CIMNormalizeSuite.