Conversation
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/CimGraph.java
Outdated
Show resolved
Hide resolved
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/CimGraph.java
Outdated
Show resolved
Hide resolved
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/CimNamespaceMapper.java
Outdated
Show resolved
Hide resolved
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/CimProfile.java
Outdated
Show resolved
Hide resolved
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/CimProfile17.java
Outdated
Show resolved
Hide resolved
| Objects.requireNonNull(cimNamespace, "cimNamespace"); | ||
| final var profile = headerProfilesByCimNamespace.get(cimNamespace); | ||
| if (profile == null) | ||
| return null; |
There was a problem hiding this comment.
Just a note on this code path: This method is public and returns a Map, so it should not return null. Please return an empty map instead (e.g., Map.of()), so callers don’t need additional null checks and we avoid potential NullPointerExceptions.
| return null; | |
| return Map.of(); |
There was a problem hiding this comment.
Thanks. I use Collections.emptyMap() now.
There was a problem hiding this comment.
Creating a HashMap via ctor with known capacity, the requested capacity is not fully allocated by default.
| final var map = HashMap.newHashMap(1_024); |
There was a problem hiding this comment.
That was not the intention here, it should simply not start too small, as there are typically a few hundred properties in CIM/CGMES.
| import java.util.concurrent.ConcurrentHashMap; | ||
| import java.util.function.Function; | ||
|
|
||
| public class CimNamespaceMapper { |
There was a problem hiding this comment.
This sounds like a naming smell. The class has members to register factories. It also has members to unregister factories.
Pls rename it.
| public class CimNamespaceMapper { | |
| public class CimNamespaceFactoryCatalog { |
| public class CimNamespaceMapper { | |
| public class CimNamespaceFactoryRegistry { |
There was a problem hiding this comment.
Great name, using CimNamespaceFactoryRegistry now.
| if(!isHeaderProfile) { | ||
| if (!CimProfile17.hasOntology(graph)) { | ||
| throw new IllegalArgumentException("Graph does not contain the required ontology subject for a CIM profile."); | ||
| } | ||
| if (!CimProfile17.hasVersionIRIAndKeyword(graph)) { | ||
| throw new IllegalArgumentException("Graphs ontology does not contain the required versionIRI and keyword for a CIM profile."); | ||
| } | ||
| } |
There was a problem hiding this comment.
Reduce nesting
| if(!isHeaderProfile) { | |
| if (!CimProfile17.hasOntology(graph)) { | |
| throw new IllegalArgumentException("Graph does not contain the required ontology subject for a CIM profile."); | |
| } | |
| if (!CimProfile17.hasVersionIRIAndKeyword(graph)) { | |
| throw new IllegalArgumentException("Graphs ontology does not contain the required versionIRI and keyword for a CIM profile."); | |
| } | |
| } | |
| if (isHeaderProfile) { | |
| return; | |
| } | |
| if (!CimProfile17.hasOntology(graph)) { | |
| throw new IllegalArgumentException("Graph does not contain the required ontology subject for a CIM profile."); | |
| } | |
| if (!CimProfile17.hasVersionIRIAndKeyword(graph)) { | |
| throw new IllegalArgumentException("Graphs ontology does not contain the required versionIRI and keyword for a CIM profile."); | |
| } |
d99c4c2 to
1a5e544
Compare
shinji-san
left a comment
There was a problem hiding this comment.
I am sorry. During a second review, I found a few more points.
| } | ||
|
|
||
| public static void registerProfileFactory(String namespace, Function<Graph, CimProfile> factory) { | ||
| Objects.requireNonNull(namespace, "namespace"); |
There was a problem hiding this comment.
Pls define a constant instead of duplicating this literal value (namespace) four times.
| public final static Node GRAPH_PRECONDITIONS = NodeFactory.createURI(GRAPH_PRECONDITIONS_URI); | ||
| public static final Node GRAPH_FORWARD_DIFFERENCES = NodeFactory.createURI(GRAPH_FORWARD_DIFFERENCES_URI); | ||
| public static final Node GRAPH_REVERSE_DIFFERENCES = NodeFactory.createURI(GRAPH_REVERSE_DIFFERENCES_URI); | ||
| public static final Node GRAPH_PRECONDITIONS = NodeFactory.createURI(GRAPH_PRECONDITIONS_URI); |
There was a problem hiding this comment.
Maybe, to prevent the class from being instantiated, you can define a private constructor. This will prevent the compiler from implicitly generating a public parameterless constructor.
| import de.soptim.opencgmes.cimxml.graph.CimProfile; | ||
| import de.soptim.opencgmes.cimxml.graph.CimProfile17; | ||
| import de.soptim.opencgmes.cimxml.graph.CimProfile18; | ||
| import de.soptim.opencgmes.cimxml.parser.CimXmlParser; |
72a39f0 to
7856af0
Compare
cimxml/src/main/java/de/soptim/opencgmes/cimxml/parser/system/StreamCimXmlToDatasetGraph.java
Show resolved
Hide resolved
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/CimModelHeader.java
Outdated
Show resolved
Hide resolved
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/CimModelHeader.java
Outdated
Show resolved
Hide resolved
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/CimProfile17.java
Outdated
Show resolved
Hide resolved
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/CimProfile17.java
Outdated
Show resolved
Hide resolved
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/DisjointMultiUnion.java
Outdated
Show resolved
Hide resolved
cimxml/src/main/java/de/soptim/opencgmes/cimxml/sparql/core/LinkedCimDatasetGraph.java
Outdated
Show resolved
Hide resolved
cimxml/src/test/java/de/soptim/opencgmes/cimxml/rdfs/CimProfileRegistryStdTest.java
Outdated
Show resolved
Hide resolved
cimxml/src/test/java/de/soptim/opencgmes/parser/TestConvertCimXmlToJsonLd.java
Outdated
Show resolved
Hide resolved
|
Please resolve the merge conflicts in the gitignore and pom.xml |
The CIMXML library now supports any cim namespace and a configurable mapping of cim namespace URIs to custom `CimProfile` implementations besides the existing `CimProfile16`, `CimProfile17` and `CimProfile18`. For this mapping, the `CimNamespaceFactoryRegistry` has been introduced. The static enum `CimVersion` has be removed and all usages have been replaced by the namespace URIs. Before, there was a fixed set of cim namespaces supported by the CIMXML library: "http://iec.ch/TC57/2013/CIM-schema-cim16#" -> `CimVersion.`; "http://iec.ch/TC57/CIM100#" -> `CimVersion.CIM_17`; "https://cim.ucaiug.io/ns#" -> `CimVersion.CIM_18`; anything else: `CimVersion.NO_CIM`; New public method CimProfileRegistry#getMatchingProfiles to find matching profile for a given set of `owlVerionIRIs`. --> this enables for generich JSON-LD export demonstrated in `TestConvertCimXmlToJsonLd` Upgraded to Jena 5.6.0 Using Apache Jena `GraphFactory.createGraphMem()` instead of specific graph implementations. This makes migration easier. Especially with the renamed graph implementation in Jena 6.0 . - added several code quality plugins - spotbugs-maven-plugin - maven-checkstyle-plugin - maven-pmd-plugin - jacoco-maven-plugin - license-maven-plugin - cyclonedx-maven-plugin (for SBOM) - using the Google coding conventions for Java (checkstyle) - configured IntelliJ for Google coding conventions for Java Refactored CIMXML handling: rename classes and methods for consistency, add code style configuration, and update .gitignore. Updated keyword for FileHeaderProfiles for compatibility with CGMES 3.0 and refactor URI handling in conversion.
7856af0 to
3af063e
Compare
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/CimModelHeader.java
Outdated
Show resolved
Hide resolved
cimxml/src/main/java/de/soptim/opencgmes/cimxml/graph/DisjointMultiUnion.java
Outdated
Show resolved
Hide resolved
… documentation in DisjointMultiUnion
… documentation in DisjointMultiUnion
wilu-soptim
left a comment
There was a problem hiding this comment.
All of my feedback has been adressed. Thank you!
Solves: Allow any cim namespace URIs #3
The CIMXML library now supports any cim namespace and a configurable mapping of cim namespace URIs to custom CimProfile implementations besides the existing CimProfile16, CimProfile17 and CimProfile18.
For this mapping, the CimNamespaceMapper has been introduced.
The static enum CimVersion has be removed and all usages have been replaced by the namespace URIs.
Before, there was a fixed set of cim namespaces supported by the CIMXML library:
"http://iec.ch/TC57/2013/CIM-schema-cim16#" -> CimVersion.CIM_16; "http://iec.ch/TC57/CIM100#" -> CimVersion.CIM_17; "https://cim.ucaiug.io/ns#" -> CimVersion.CIM_18;
anything else: CimVersion.NO_CIM;