Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/webvowl/js/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,34 @@ module.exports = function ( graph ){
// Process the graph data
convertTypesToIris(combinedClassesAndDatatypes, ontologyData.namespace);
convertTypesToIris(combinedProperties, ontologyData.namespace);

// Collect all domain and range references from properties (fix #172)
// Ensure every referenced class has a node even if not declared in the ontology
var referencedClassIds = {};
combinedProperties.forEach(function ( property ) {
if ( property.domain() && typeof property.domain() === "string" ) {
referencedClassIds[property.domain()] = true;
}
if ( property.range() && typeof property.range() === "string" ) {
referencedClassIds[property.range()] = true;
}
});

// Add missing referenced classes as placeholder nodes
var missingClasses = [];
for ( var cid in referencedClassIds ) {
if ( !classMap.hasOwnProperty(cid) ) {
var Placeholder = require("./elements/nodes/implementations/OwlClass");
var missingNode = new Placeholder(graph);
missingNode.id(cid).visible(true);
missingNode.label({ "default": cid });
missingClasses.push(missingNode);
}
}
if ( missingClasses.length > 0 ) {
combinedClassesAndDatatypes = combinedClassesAndDatatypes.concat(missingClasses);
}

nodes = createNodeStructure(combinedClassesAndDatatypes, classMap);
properties = createPropertyStructure(combinedProperties, classMap, propertyMap);
};
Expand Down