Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#15316] feat(common): Convert and validate Ossie ontology documents (#15317)

mchades4019c7244c36
diff --git a/LICENSE b/LICENSE
index 3732339e97..7599af49d0 100644
--- a/LICENSE
+++ b/LICENSE
@@ -211,6 +211,11 @@
./gradlew
./gradle/wrapper/gradle-wrapper.properties
+ Apache Ossie (incubating) (https://github.com/apache/ossie)
+ ./common/src/main/resources/ossie/core-spec/ossie-schema.json
+ ./common/src/main/resources/ossie/ontology/ontology.json
+ ./common/src/testFixtures/resources/ossie/ontology/flights.ontology.yaml
+
Apache Spark
./api/src/main/java/org/apache/gravitino/SchemaChange.java
./api/src/main/java/org/apache/gravitino/SupportsSchemas.java
diff --git a/LICENSE.bin b/LICENSE.bin
index 4381653753..754e5f229e 100644
--- a/LICENSE.bin
+++ b/LICENSE.bin
@@ -206,6 +206,9 @@
This product bundles various third-party components also under the
Apache Software License 2.0 from:
+ Apache Ossie (ontology schema)
+ NetworkNT JSON Schema Validator
+ Ethlo Time ITU
Apache Hive
Apache Paimon
FastDoubleParser (older Jackson copy shaded in paimon-format 1.2.0)
diff --git a/NOTICE b/NOTICE
index 243cf43e93..cfb6d4c9c2 100644
--- a/NOTICE
+++ b/NOTICE
@@ -10,6 +10,9 @@ to the ASF by Datastrato (https://datastrato.ai/) copyright 2023-2024.
The Web UI also has NOTICE files, please see web/web/NOTICE and
web-v2/web/NOTICE for their contents.
+Apache Ossie (incubating)
+Copyright 2026 The Apache Software Foundation
+
Apache Iceberg
Copyright 2017-2022 The Apache Software Foundation
diff --git a/build.gradle.kts b/build.gradle.kts
index 485d3ae749..214cd1b6a7 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -832,7 +832,7 @@ subprojects {
// These notices cover copied production sources, not dependencies declared only in the POM.
val sourceNoticeNames = mapOf(
":api" to listOf("spark", "iceberg"),
- ":common" to listOf("iceberg", "hadoop"),
+ ":common" to listOf("iceberg", "hadoop", "ossie"),
":core" to listOf("spark", "iceberg", "kafka", "aws"),
":clients:client-java" to listOf("iceberg"),
":bundles:aws" to listOf("doris"),
diff --git a/common/build.gradle.kts b/common/build.gradle.kts
index 1587b91362..a1d12b7766 100644
--- a/common/build.gradle.kts
+++ b/common/build.gradle.kts
@@ -41,11 +41,19 @@ dependencies {
annotationProcessor(libs.lombok)
compileOnly(libs.commons.dbcp2)
compileOnly(libs.jackson.dataformat.yaml)
+ compileOnly(libs.json.schema.validator) {
+ exclude(group = "com.fasterxml.jackson.core", module = "jackson-databind")
+ exclude(group = "com.fasterxml.jackson.dataformat", module = "jackson-dataformat-yaml")
+ }
compileOnly(libs.lombok)
testAnnotationProcessor(libs.lombok)
testCompileOnly(libs.lombok)
testImplementation(libs.jackson.dataformat.yaml)
+ testImplementation(libs.json.schema.validator) {
+ exclude(group = "com.fasterxml.jackson.core", module = "jackson-databind")
+ exclude(group = "com.fasterxml.jackson.dataformat", module = "jackson-dataformat-yaml")
+ }
testImplementation(libs.junit.jupiter.api)
testImplementation(libs.junit.jupiter.params)
diff --git a/common/src/main/java/org/apache/gravitino/ontology/OntologyReferences.java b/common/src/main/java/org/apache/gravitino/ontology/OntologyReferences.java
new file mode 100644
index 0000000000..c7f9589042
--- /dev/null
+++ b/common/src/main/java/org/apache/gravitino/ontology/OntologyReferences.java
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.ontology;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableSet;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import javax.annotation.Nullable;
+import org.apache.gravitino.exceptions.IllegalOntologyException;
+
+/** Indexes a structurally validated ontology and checks its structured references. */
+public final class OntologyReferences {
+
+ private static final Set<String> BUILT_INS =
+ ImmutableSet.of(
+ "Any", "Boolean", "Date", "DateTime", "Decimal", "Float", "Integer", "String");
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ private final Map<String, Concept> concepts = new LinkedHashMap<>();
+
+ private OntologyReferences(OntologyDefinition definition) {
+ JsonNode root = MAPPER.valueToTree(definition.fields());
+ visit(
+ root.path("ontology"),
+ "$.ontology",
+ (node, path) -> {
+ String name = node.path("concept").asText();
+ if (BUILT_INS.contains(name)
+ || concepts.putIfAbsent(name, new Concept(node, path)) != null) {
+ throw new IllegalOntologyException(
+ "%s.concept: duplicate or built-in concept '%s'", path, name);
+ }
+ });
+ concepts.values().forEach(this::validateDeclaration);
+ validateInheritance();
+ concepts.forEach(
+ (name, concept) ->
+ visit(
+ concept.node.path("identifyBy"),
+ concept.path + ".identifyBy",
+ (item, path) -> {
+ String identifier = item.asText();
+ JsonNode relationship = findRelationshipByDeclaredName(name, identifier);
+ if (relationship == null) {
+ throw new IllegalOntologyException(
+ "%s: unknown identifying relationship '%s'", path, identifier);
+ }
+ if (relationship.path("roles").size() != 1) {
+ throw new IllegalOntologyException(
+ "%s: identifying relationship '%s' must be binary", path, identifier);
+ }
+ }));
+ }
+
+ /**
+ * Validates ontology names, inheritance, and relationship references and builds an index.
+ *
+ * @param definition The ontology definition after structural validation.
+ * @return The validated ontology index.
+ */
+ public static OntologyReferences of(OntologyDefinition definition) {
+ return new OntologyReferences(definition);
+ }
+
+ private void validateDeclaration(Concept concept) {
+ String conceptName = concept.node.path("concept").asText();
+ visit(
+ concept.node.path("extends"),
+ concept.path + ".extends",
+ (item, path) -> {
+ String parent = item.asText();
+ requireOntologyConcept(parent, path);
+ concept.parents.add(parent);
+ });
+ visit(
+ concept.node.path("relationships"),
+ concept.path + ".relationships",
+ (node, path) -> {
+ String name = node.path("name").asText();
+ if (concept.relationships.putIfAbsent(name, node) != null) {
+ throw new IllegalOntologyException("%s.name: duplicate relationship '%s'", path, name);
+ }
+ if (node.path("verbalizes").isEmpty()) {
+ throw new IllegalOntologyException(
+ "%s.verbalizes: at least one verbalization is required", path);
+ }
+ Set<String> roleNames = new HashSet<>();
+ roleNames.add(conceptName);
+ visit(
+ node.path("roles"),
+ path + ".roles",
+ (role, rolePath) -> {
+ String roleConcept = role.path("concept").asText();
+ requireOntologyConcept(roleConcept, rolePath + ".concept");
+ String roleName = role.path("name").asText(roleConcept);
+ if (!roleNames.add(roleName)) {
+ throw new IllegalOntologyException(
+ "%s: duplicate role name '%s'", rolePath, roleName);
+ }
+ });
+ });
+ }
+
+ private void validateInheritance() {
+ // Removing root concepts and their edges leaves exactly the cycles and their dependents.
+ Map<String, List<String>> children = new HashMap<>();
+ Map<String, Integer> remainingParents = new LinkedHashMap<>();
+ Deque<String> roots = new ArrayDeque<>(BUILT_INS);
+ concepts.forEach(
+ (name, concept) -> {
+ remainingParents.put(name, concept.parents.size());
+ if (concept.parents.isEmpty()) {
+ roots.addLast(name);
+ }
+ concept.parents.forEach(
+ parent -> children.computeIfAbsent(parent, ignored -> new ArrayList<>()).add(name));
+ });
+ while (!roots.isEmpty()) {
+ String resolved = roots.removeFirst();
+ remainingParents.remove(resolved);
+ if (!children.containsKey(resolved)) {
+ continue;
+ }
+ for (String child : children.get(resolved)) {
+ if (remainingParents.computeIfPresent(child, (name, pending) -> pending - 1) == 0) {
+ roots.addLast(child);
+ }
+ }
+ }
+ if (!remainingParents.isEmpty()) {
+ String remaining = remainingParents.keySet().iterator().next();
+ throw new IllegalOntologyException(
+ "%s.extends: inheritance cycle involving or inherited by '%s'",
+ concepts.get(remaining).path, remaining);
+ }
+ }
+
+ @Nullable
+ private JsonNode findRelationshipByDeclaredName(String concept, String name) {
+ for (String ancestor : lineage(concept)) {
+ Concept declaration = concepts.get(ancestor);
+ if (declaration != null && declaration.relationships.containsKey(name)) {
+ return declaration.relationships.get(name);
+ }
+ }
+ return null;
+ }
+
+ private List<String> lineage(String name) {
+ List<String> ordered = new ArrayList<>();
+ Set<String> visited = new HashSet<>();
+ Deque<String> pending = new ArrayDeque<>();
+ pending.push(name);
+ while (!pending.isEmpty()) {
+ String current = pending.pop();
+ if (!visited.add(current)) {
+ continue;
+ }
+ ordered.add(current);
+ Concept declaration = concepts.get(current);
+ if (declaration != null) {
+ for (int i = declaration.parents.size() - 1; i >= 0; i--) {
+ pending.push(declaration.parents.get(i));
+ }
+ }
+ }
+ return ordered;
+ }
+
+ private boolean hasConcept(String name) {
+ return BUILT_INS.contains(name) || concepts.containsKey(name);
+ }
+
+ private void requireOntologyConcept(String name, String path) {
+ if (!hasConcept(name)) {
+ throw new IllegalOntologyException("%s: unknown concept '%s'", path, name);
+ }
+ }
+
+ private static void visit(JsonNode items, String path, BiConsumer<JsonNode, String> visitor) {
+ for (int i = 0; i < items.size(); i++) {
+ visitor.accept(items.get(i), path + "[" + i + "]");
+ }
+ }
+
+ private static final class Concept {
+
+ private final JsonNode node;
+ private final String path;
+ private final List<String> parents = new ArrayList<>();
+ private final Map<String, JsonNode> relationships = new HashMap<>();
+
+ private Concept(JsonNode node, String path) {
+ this.node = node;
+ this.path = path;
+ }
+ }
+}
diff --git a/common/src/main/java/org/apache/gravitino/ontology/OssieOntologyDocuments.java b/common/src/main/java/org/apache/gravitino/ontology/OssieOntologyDocuments.java
new file mode 100644
index 0000000000..14626a3e1a
--- /dev/null
+++ b/common/src/main/java/org/apache/gravitino/ontology/OssieOntologyDocuments.java
@@ -0,0 +1,417 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.ontology;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.StreamReadFeature;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
+import com.google.common.collect.ImmutableBiMap;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.JsonSchemaFactory;
+import com.networknt.schema.PathType;
+import com.networknt.schema.SchemaLocation;
+import com.networknt.schema.SchemaValidatorsConfig;
+import com.networknt.schema.SpecVersion;
+import com.networknt.schema.ValidationMessage;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.exceptions.IllegalOntologyException;
+import org.apache.gravitino.semantic.OssieDocument;
+import org.apache.gravitino.semantic.OssieFormat;
+
+/**
+ * Converts standalone Ossie ontology documents using the bundled schema pin.
+ *
+ * <p>The schemas under {@code ossie/} are copied from <a
+ * href="https://github.com/apache/ossie/tree/3719487ff2744b207d0cc9bed66f5406f410dc3d">Apache Ossie
+ * at 3719487</a>, and every schema reference resolves against these bundled resources. Gravitino
+ * accepts any nonempty document version, so the root {@code version} constraint in {@code
+ * ontology/ontology.json} uses {@code minLength: 1}. Re-apply that change when the schema is
+ * updated from upstream; {@code TestOssieOntologyDocuments#testAnyNonBlankVersionIsAccepted} fails
+ * otherwise.
+ */
+public final class OssieOntologyDocuments {
+
+ /** The Ossie version for new native ontologies. */
+ public static final String DEFAULT_VERSION = "0.3.0.dev0";
+
+ /** The property that carries the version written to an Ossie document. */
+ public static final String VERSION_PROPERTY = "ossie-version";
+
+ private static final String ANNOTATIONS = "annotations";
+ private static final String ONTOLOGY_PROPERTIES = "gravitino_properties";
+ private static final TypeReference<Map<String, Object>> FIELDS =
+ new TypeReference<Map<String, Object>>() {};
+ private static final Set<String> OPAQUE_FIELDS =
+ ImmutableSet.of(ANNOTATIONS, "prefixes", "ai_context", "aiContext");
+ private static final ImmutableBiMap<String, String> OSSIE_TO_NATIVE =
+ ImmutableBiMap.<String, String>builder()
+ .put("ai_context", "aiContext")
+ .put("identify_by", "identifyBy")
+ .put("derived_by", "derivedBy")
+ .build();
+
+ private static final ObjectMapper JSON =
+ configure(
+ new ObjectMapper(
+ JsonFactory.builder().enable(StreamReadFeature.STRICT_DUPLICATE_DETECTION).build()));
+ private static final ObjectMapper YAML =
+ configure(
+ new ObjectMapper(
+ YAMLFactory.builder()
+ .enable(StreamReadFeature.STRICT_DUPLICATE_DETECTION)
+ .disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)
+ .build()));
+
+ private static final JsonSchemaFactory SCHEMAS =
+ JsonSchemaFactory.getInstance(
+ SpecVersion.VersionFlag.V202012,
+ builder ->
+ builder.schemaMappers(
+ mappers ->
+ mappers
+ .mapPrefix(
+ "https://raw.githubusercontent.com/apache/ossie/main/",
+ "classpath:ossie/")
+ .mapPrefix("https://github.com/apache/ossie/", "classpath:ossie/")));
+
+ private OssieOntologyDocuments() {}
+
+ /**
+ * Parses and validates a standalone Ossie ontology.
+ *
+ * @param document The input document.
+ * @return A validated ontology suitable for creation.
+ */
+ public static ParsedOntology importOntology(OssieDocument document) {
+ ObjectNode root = read(document, Kind.ONTOLOGY);
+ ObjectNode annotations = (ObjectNode) root.get(ANNOTATIONS);
+ JsonNode stored = annotations == null ? null : annotations.remove(ONTOLOGY_PROPERTIES);
+ if (stored != null && annotations.isEmpty()) {
+ root.remove(ANNOTATIONS);
+ }
+ Map<String, String> properties =
+ readProperties(root, stored, "$.annotations." + ONTOLOGY_PROPERTIES);
+ return new ParsedOntology(
+ root.path("name").asText(),
+ comment(root),
+ OntologyDefinition.of(readDefinition(root, Kind.ONTOLOGY)),
+ properties);
+ }
+
+ /**
+ * Exports an ontology to a standalone Ossie document.
+ *
+ * @param ontology The current ontology.
+ * @param format The output format.
+ * @return The exported document.
+ */
+ public static OssieDocument exportOntology(Ontology ontology, OssieFormat format) {
+ return write(
+ ontologyRoot(
+ ontology.name(), ontology.comment(), ontology.definition(), ontology.properties()),
+ Kind.ONTOLOGY,
+ format);
+ }
+
+ /**
+ * Validates a native ontology against the pinned Ossie document shape.
+ *
+ * @param name The ontology name.
+ * @param comment The optional ontology description.
+ * @param definition The native definition.
+ * @param properties The properties to export.
+ */
+ public static void validateOntology(
+ String name,
+ @Nullable String comment,
+ OntologyDefinition definition,
+ Map<String, String> properties) {
+ validate(ontologyRoot(name, comment, definition, properties), Kind.ONTOLOGY);
+ }
+
+ private static ObjectMapper configure(ObjectMapper mapper) {
+ return mapper
+ .enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
+ .enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
+ }
+
+ private static ObjectNode ontologyRoot(
+ String name,
+ @Nullable String comment,
+ OntologyDefinition definition,
+ Map<String, String> properties) {
+ ObjectNode root = root(Kind.ONTOLOGY, name, comment, definition.fields(), properties);
+ ObjectNode props = propertiesNode(properties);
+ ObjectNode annotations = objectField(root, ANNOTATIONS);
+ if (annotations != null && annotations.has(ONTOLOGY_PROPERTIES)) {
+ throw invalid("$.annotations." + ONTOLOGY_PROPERTIES + " is reserved");
+ }
+ if (!props.isEmpty()) {
+ if (annotations == null) {
+ annotations = root.putObject(ANNOTATIONS);
+ }
+ annotations.set(ONTOLOGY_PROPERTIES, props);
+ }
+ return root;
+ }
+
+ private static ObjectNode root(
+ Kind kind,
+ String name,
+ @Nullable String description,
+ Map<String, Object> fields,
+ Map<String, String> properties) {
+ ObjectNode root = JSON.createObjectNode();
+ root.put("name", name);
+ String version = properties.getOrDefault(VERSION_PROPERTY, DEFAULT_VERSION);
+ if (StringUtils.isBlank(version)) {
+ throw invalid("$.version must be non-blank");
+ }
+ root.put("version", version);
+ if (description != null) {
+ root.put("description", description);
+ }
+ ObjectNode definition = (ObjectNode) remap(JSON.valueToTree(fields), false, "$");
+ definition
+ .fields()
+ .forEachRemaining(
+ entry -> {
+ if (!kind.definitionFields.contains(entry.getKey())) {
+ throw invalid("$." + entry.getKey() + " is not a definition field");
+ }
+ root.set(entry.getKey(), entry.getValue());
+ });
+ return root;
+ }
+
+ private static ObjectNode read(OssieDocument document, Kind kind) {
+ JsonNode input;
+ try {
+ input = (document.format() == OssieFormat.JSON ? JSON : YAML).readTree(document.content());
+ } catch (JsonProcessingException e) {
+ throw invalid("$: " + e.getOriginalMessage());
+ }
+ if (input == null || !input.isObject()) {
+ throw invalid("$ must be an object");
+ }
+ ObjectNode root = (ObjectNode) input;
+ if (root.has("ontology_mappings")) {
+ throw invalid("$.ontology_mappings is deprecated; import a standalone mapping");
+ }
+ validate(root, kind);
+ if (StringUtils.isBlank(root.path("version").asText())
+ || StringUtils.isBlank(root.path("name").asText())) {
+ throw invalid("$.version and $.name must be non-blank");
+ }
+ return root;
+ }
+
+ private static OssieDocument write(ObjectNode root, Kind kind, OssieFormat format) {
+ validate(root, kind);
+ try {
+ if (format == OssieFormat.JSON) {
+ return OssieDocument.json(
+ JSON.writerWithDefaultPrettyPrinter().writeValueAsString(root) + "\n");
+ }
+ return OssieDocument.yaml(YAML.writeValueAsString(root));
+ } catch (IOException e) {
+ throw invalid("$: Cannot serialize Ossie document: " + e.getMessage());
+ }
+ }
+
+ private static void validate(ObjectNode root, Kind kind) {
+ Set<ValidationMessage> problems = kind.schema.validate(root);
+ if (!problems.isEmpty()) {
+ throw invalid(problems.iterator().next().getMessage());
+ }
+ }
+
+ private static Map<String, Object> readDefinition(ObjectNode root, Kind kind) {
+ ObjectNode definition = JSON.createObjectNode();
+ for (String key : kind.definitionFields) {
+ if (root.has(key)) {
+ definition.set(key, root.get(key));
+ }
+ }
+ return JSON.convertValue(remap(definition, true, "$"), FIELDS);
+ }
+
+ private static JsonNode remap(JsonNode node, boolean toNative, String path) {
+ if (node.isArray()) {
+ ArrayNode result = JSON.createArrayNode();
+ for (int i = 0; i < node.size(); i++) {
+ result.add(remap(node.get(i), toNative, path + "[" + i + "]"));
+ }
+ return result;
+ }
+ if (!node.isObject()) {
+ return node;
+ }
+ ObjectNode result = JSON.createObjectNode();
+ node.fields()
+ .forEachRemaining(
+ entry -> {
+ String name = entry.getKey();
+ String childPath = path + "." + name;
+ if (!toNative && OSSIE_TO_NATIVE.containsKey(name)) {
+ throw invalid(childPath + " must use its Gravitino camel-case spelling");
+ }
+ String mapped =
+ (toNative ? OSSIE_TO_NATIVE : OSSIE_TO_NATIVE.inverse()).getOrDefault(name, name);
+ result.set(
+ mapped,
+ OPAQUE_FIELDS.contains(name)
+ ? entry.getValue()
+ : remap(entry.getValue(), toNative, childPath));
+ });
+ return result;
+ }
+
+ @Nullable
+ private static ObjectNode objectField(ObjectNode root, String field) {
+ JsonNode node = root.get(field);
+ if (node != null && !node.isObject()) {
+ throw invalid("$." + field + " must be an object");
+ }
+ return (ObjectNode) node;
+ }
+
+ private static ObjectNode propertiesNode(Map<String, String> properties) {
+ ObjectNode node = JSON.createObjectNode();
+ properties.forEach(
+ (key, value) -> {
+ if (!key.equals(VERSION_PROPERTY)) {
+ node.put(key, value);
+ }
+ });
+ return node;
+ }
+
+ private static Map<String, String> readProperties(
+ ObjectNode root, @Nullable JsonNode stored, String path) {
+ Map<String, String> properties = new LinkedHashMap<>();
+ if (stored != null) {
+ if (!stored.isObject()) {
+ throw invalid(path + " must be an object of string properties");
+ }
+ stored
+ .fields()
+ .forEachRemaining(
+ entry -> {
+ if (!entry.getValue().isTextual()) {
+ throw invalid(path + "." + entry.getKey() + " must be a string");
+ }
+ properties.put(entry.getKey(), entry.getValue().asText());
+ });
+ }
+ properties.put(VERSION_PROPERTY, root.path("version").asText());
+ return ImmutableMap.copyOf(properties);
+ }
+
+ @Nullable
+ private static String comment(ObjectNode root) {
+ return root.has("description") ? root.path("description").asText() : null;
+ }
+
+ private static IllegalArgumentException invalid(String detail) {
+ return new IllegalOntologyException("%s", detail);
+ }
+
+ private static final class Kind {
+ private static final Kind ONTOLOGY =
+ new Kind(
+ "ontology.json",
+ ImmutableSet.of("ai_context", "prefixes", "requires", ANNOTATIONS, "ontology"));
+
+ private final JsonSchema schema;
+ private final Set<String> definitionFields;
+
+ Kind(String file, Set<String> definitionFields) {
+ this.definitionFields = definitionFields;
+ this.schema =
+ SCHEMAS.getSchema(
+ SchemaLocation.of("classpath:ossie/ontology/" + file),
+ SchemaValidatorsConfig.builder()
+ .pathType(PathType.JSON_PATH)
+ .formatAssertionsEnabled(true)
+ .build());
+ }
+ }
+ /** A parsed Ossie ontology before it has been persisted. */
+ public static final class ParsedOntology {
+ private final String name;
+ @Nullable private final String comment;
+ private final OntologyDefinition definition;
+ private final Map<String, String> properties;
+
+ private ParsedOntology(
+ String name,
+ @Nullable String comment,
+ OntologyDefinition definition,
+ Map<String, String> properties) {
+ this.name = name;
+ this.comment = comment;
+ this.definition = definition;
+ this.properties = properties;
+ }
+
+ /**
+ * @return The name from the Ossie document.
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * @return The optional description.
+ */
+ public @Nullable String comment() {
+ return comment;
+ }
+
+ /**
+ * @return The native ontology definition.
+ */
+ public OntologyDefinition definition() {
+ return definition;
+ }
+
+ /**
+ * @return The properties including the source version.
+ */
+ public Map<String, String> properties() {
+ return properties;
+ }
+ }
+}
diff --git a/common/src/main/resources/ossie/core-spec/ossie-schema.json b/common/src/main/resources/ossie/core-spec/ossie-schema.json
new file mode 100644
index 0000000000..6fcbc83e5f
--- /dev/null
+++ b/common/src/main/resources/ossie/core-spec/ossie-schema.json
@@ -0,0 +1,398 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://github.com/apache/ossie/core-spec/ossie-schema.json",
+ "title": "Apache Ossie Core Metadata Specification",
+ "description": "JSON Schema for validating a single Apache Ossie semantic model document",
+ "type": "object",
+ "properties": {
+ "version": {
+ "type": "string",
+ "const": "0.3.0.dev0",
+ "description": "Apache Ossie specification version"
+ },
+ "name": {
+ "$ref": "#/$defs/SemanticModel/properties/name"
+ },
+ "description": {
+ "$ref": "#/$defs/SemanticModel/properties/description"
+ },
+ "ai_context": {
+ "$ref": "#/$defs/SemanticModel/properties/ai_context"
+ },
+ "datasets": {
+ "$ref": "#/$defs/SemanticModel/properties/datasets"
+ },
+ "relationships": {
+ "$ref": "#/$defs/SemanticModel/properties/relationships"
+ },
+ "metrics": {
+ "$ref": "#/$defs/SemanticModel/properties/metrics"
+ },
+ "nonportable_extensions": {
+ "$ref": "#/$defs/SemanticModel/properties/nonportable_extensions"
+ }
+ },
+ "required": ["version", "name", "datasets"],
+ "additionalProperties": false,
+ "$defs": {
+ "Dialect": {
+ "type": "string",
+ "minLength": 1,
+ "examples": ["OSSIE_SQL_2026", "ANSI_SQL", "DB_DIALECT", "BI_EXPRESSION", "SEMANTIC_MODEL_EXPRESSION", "PROGRAMMING_LANGUAGE"],
+ "description": "Expression language a metric or field expression is declared in. Any non-empty string is accepted. OSSIE_SQL_2026 is the only dialect this specification defines; others are opaque to Ossie. See extensions/dialects.md."
+ },
+ "Vendor": {
+ "type": "string",
+ "minLength": 1,
+ "examples": ["BI_TOOL", "DB_VENDOR", "SEMANTIC_LAYER"],
+ "description": "Vendor name for non-portable extensions. Any non-empty string is accepted. See extensions/vendors.md."
+ },
+ "AIContext": {
+ "description": "Additional context for AI tools",
+ "oneOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "instructions": {
+ "type": "string",
+ "description": "Instructions for AI on how to use this entity"
+ },
+ "synonyms": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Alternative names and terms"
+ },
+ "examples": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Sample questions or use cases"
+ }
+ },
+ "additionalProperties": true
+ }
+ ]
+ },
+ "NonportableExtension": {
+ "type": "object",
+ "description": "Vendor-specific state that Ossie carries and does not interpret. Portable behavior does not depend on it.",
+ "properties": {
+ "vendor_name": {
+ "$ref": "#/$defs/Vendor"
+ },
+ "data": {
+ "type": "object",
+ "description": "Vendor-specific data as a structured object. The core schema does not reference the structure under data: no reserved key and no common sub-key. Keys are entirely vendor-defined. Values must be JSON-representable. Ossie carries the object but does not interpret it. See core-spec/spec.md#non-portable-extensions."
+ }
+ },
+ "required": ["vendor_name", "data"],
+ "additionalProperties": false
+ },
+ "DialectExpression": {
+ "type": "object",
+ "description": "Expression in a specific dialect",
+ "properties": {
+ "dialect": {
+ "$ref": "#/$defs/Dialect"
+ },
+ "expression": {
+ "type": "string",
+ "minLength": 1,
+ "description": "SQL or dialect-specific expression"
+ }
+ },
+ "required": ["dialect", "expression"],
+ "additionalProperties": false
+ },
+ "Expression": {
+ "type": "object",
+ "description": "Expression definition with multi-dialect support",
+ "properties": {
+ "sql": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Primary, portable expression written in OSSIE_SQL_2026. When both this field and an OSSIE_SQL_2026 entry in `dialects` are present, this field is authoritative."
+ },
+ "dialects": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/DialectExpression"
+ },
+ "minItems": 1
+ }
+ },
+ "anyOf": [
+ { "required": ["sql"] },
+ { "required": ["dialects"] }
+ ],
+ "additionalProperties": false
+ },
+ "DataType": {
+ "type": "string",
+ "enum": [
+ "String",
+ "Integer",
+ "Decimal",
+ "Float",
+ "Boolean",
+ "Date",
+ "Time",
+ "DateTime",
+ "DateTimeTz",
+ "Opaque"
+ ],
+ "description": "Logical data type for fields and metrics, independent of role (e.g. dimension vs fact) and physical representation. `Decimal` is exact base-10 with unspecified precision and scale; `Float` is approximate. `DateTime` has no timezone or offset, while `DateTimeTz` identifies an instant using offset or timezone context but does not guarantee preservation of a named timezone. Omit `datatype` when unknown. `Opaque` means the type is outside the portable vocabulary. A vendor may record its own type name under `nonportable_extensions`; that record is not part of the portable type."
+ },
+ "Dimension": {
+ "type": "object",
+ "description": "Dimension metadata",
+ "properties": {
+ "is_time": {
+ "type": "boolean",
+ "description": "Temporal-role marker. When true, consumers that distinguish time dimensions (e.g. for time-series analysis or temporal filtering) should treat this field as a time dimension. This is a *role* flag, independent of the field's data type: a field with `is_time: true` may carry any `datatype` (e.g. `Integer` for a year grain, `String` for a month name, as well as temporal data types). When `is_time` is unset, it defaults to `true` if `datatype` is one of `Date`, `Time`, `DateTime`, or `DateTimeTz`, and `false` otherwise. Set `is_time: false` explicitly to opt a temporal-typed column (such as an audit timestamp) out of time-dimension treatment."
+ }
+ },
+ "additionalProperties": false
+ },
+ "Field": {
+ "type": "object",
+ "description": "Row-level attribute for grouping, filtering, and metric expressions",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Unique identifier for the field within the dataset"
+ },
+ "expression": {
+ "$ref": "#/$defs/Expression"
+ },
+ "dimension": {
+ "$ref": "#/$defs/Dimension"
+ },
+ "label": {
+ "type": "string",
+ "description": "Label for categorization"
+ },
+ "description": {
+ "type": "string",
+ "description": "Human-readable description"
+ },
+ "datatype": {
+ "$ref": "#/$defs/DataType"
+ },
+ "ai_context": {
+ "$ref": "#/$defs/AIContext"
+ },
+ "nonportable_extensions": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/NonportableExtension"
+ }
+ }
+ },
+ "required": ["name", "expression"],
+ "additionalProperties": false
+ },
+ "Dataset": {
+ "type": "object",
+ "description": "Logical dataset representing a business entity (fact or dimension table)",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Unique identifier for the dataset"
+ },
+ "source": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Reference to underlying physical table/view (database.schema.table) or query"
+ },
+ "primary_key": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "minItems": 1,
+ "uniqueItems": true,
+ "description": "Dataset fields that uniquely identify rows, each named once"
+ },
+ "unique_keys": {
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "minItems": 1,
+ "uniqueItems": true
+ },
+ "minItems": 1,
+ "description": "Array of unique key definitions, each a list of dataset fields naming each field once"
+ },
+ "description": {
+ "type": "string",
+ "description": "Human-readable description"
+ },
+ "ai_context": {
+ "$ref": "#/$defs/AIContext"
+ },
+ "fields": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Field"
+ },
+ "description": "The dataset's declared fields. Within the dataset, field names and metric names share one namespace and must all be unique across the two."
+ },
+ "metrics": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Metric"
+ },
+ "description": "Dataset-scoped metrics: aggregations evaluated at this dataset's row level, for measures that semantically belong to the dataset. The expression references this dataset's declared fields by single-part (unqualified) name, and columns of the dataset's source as source.column. It must resolve entirely within this dataset; an expression that must reference another dataset belongs in the model-scoped metrics instead. Within the dataset, field names and metric names share one namespace and must all be unique across the two."
+ },
+ "nonportable_extensions": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/NonportableExtension"
+ }
+ }
+ },
+ "required": ["name", "source"],
+ "additionalProperties": false
+ },
+ "Relationship": {
+ "type": "object",
+ "description": "Foreign key relationship between datasets",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Unique identifier for the relationship"
+ },
+ "from": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Dataset on the many side of the relationship"
+ },
+ "to": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Dataset on the one side of the relationship"
+ },
+ "from_columns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "minItems": 1,
+ "description": "Array of field names in the 'from' dataset (foreign key fields)"
+ },
+ "to_columns": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "minItems": 1,
+ "description": "Array of field names in the 'to' dataset (primary or unique key fields)"
+ },
+ "ai_context": {
+ "$ref": "#/$defs/AIContext"
+ },
+ "nonportable_extensions": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/NonportableExtension"
+ }
+ }
+ },
+ "required": ["name", "from", "to", "from_columns", "to_columns"],
+ "additionalProperties": false
+ },
+ "Metric": {
+ "type": "object",
+ "description": "Quantitative measure defined on business data",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Unique identifier for the metric"
+ },
+ "expression": {
+ "$ref": "#/$defs/Expression"
+ },
+ "description": {
+ "type": "string",
+ "description": "Human-readable description of what the metric measures"
+ },
+ "datatype": {
+ "$ref": "#/$defs/DataType"
+ },
+ "ai_context": {
+ "$ref": "#/$defs/AIContext"
+ },
+ "nonportable_extensions": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/NonportableExtension"
+ }
+ }
+ },
+ "required": ["name", "expression"],
+ "additionalProperties": false
+ },
+ "SemanticModel": {
+ "type": "object",
+ "description": "Top-level container representing a complete semantic model",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Unique identifier for the semantic model"
+ },
+ "description": {
+ "type": "string",
+ "description": "Human-readable description"
+ },
+ "ai_context": {
+ "$ref": "#/$defs/AIContext"
+ },
+ "datasets": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Dataset"
+ },
+ "minItems": 1,
+ "description": "Collection of logical datasets"
+ },
+ "relationships": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Relationship"
+ },
+ "description": "Defines how datasets are connected"
+ },
+ "metrics": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Metric"
+ },
+ "description": "Model-scoped metrics: aggregations that span datasets or need to be aware of cross-dataset concepts. Expressions reference fields by multi-part name (dataset.field) and may combine fields from more than one dataset. They may evaluate a dataset-scoped metric with AGG(dataset.metric). Names must be unique across the model. See core-spec/spec.md#metric-scoping."
+ },
+ "nonportable_extensions": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/NonportableExtension"
+ }
+ }
+ },
+ "required": ["name", "datasets"],
+ "additionalProperties": false
+ }
+ }
+}
diff --git a/common/src/main/resources/ossie/ontology/ontology.json b/common/src/main/resources/ossie/ontology/ontology.json
new file mode 100644
index 0000000000..2c90f2c59a
--- /dev/null
+++ b/common/src/main/resources/ossie/ontology/ontology.json
@@ -0,0 +1,364 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://github.com/apache/ossie/ontology/ontology.json",
+ "title": "Apache Ossie Ontology Metadata Specification",
+ "description": "JSON Schema for validating Apache Ossie ontology definitions",
+ "type": "object",
+ "properties": {
+ "version": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Ontology specification version"
+ },
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Unique identifier for the ontology"
+ },
+ "description": {
+ "type": "string",
+ "description": "Human-readable description"
+ },
+ "ai_context": {
+ "$ref": "https://raw.githubusercontent.com/apache/ossie/main/core-spec/ossie-schema.json#/$defs/AIContext"
+ },
+ "requires": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Expression"
+ },
+ "uniqueItems": true,
+ "description": "Expressions that constrain the population of this ontology"
+ },
+ "ontology": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/OntologyComponent"
+ },
+ "minItems": 1,
+ "description": "Components that define the concepts and relationships in this ontology"
+ },
+ "ontology_mappings": {
+ "type": "array",
+ "description": "Deprecated. Embedded ontology maps, accepted only so existing documents continue to validate; write mappings as standalone documents validated against ontology/mapping.json instead.",
+ "deprecated": true,
+ "items": {
+ "$ref": "#/$defs/OntologyMap"
+ }
+ },
+ "annotations": {
+ "$ref": "#/$defs/Annotations"
+ },
+ "prefixes": {
+ "type": "object",
+ "description": "Maps namespace prefixes to the IRIs they abbreviate, enabling QName expansion (e.g., 'foaf' -> 'http://xmlns.com/foaf/0.1/').",
+ "additionalProperties": {
+ "type": "string",
+ "minLength": 1,
+ "format": "iri"
+ }
+ }
+ },
+ "required": ["version", "name", "ontology"],
+ "additionalProperties": false,
+ "$defs": {
+ "Annotations": {
+ "type": "object",
+ "description": "Open set of annotations for carrying data that is not covered by the core ontology spec, for example when importing an ontology from an external format such as OWL/RDF. Keys are free-form and values may be any JSON; the spec does not interpret their structure.",
+ "additionalProperties": true
+ },
+ "OntologyComponent": {
+ "type": "object",
+ "description": "Ontology component that defines a single concept and any relationships that are keyed primarily by that concept",
+ "properties": {
+ "concept": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Unique name of the concept defined by this component"
+ },
+ "type": {
+ "$ref": "#/$defs/ConceptType"
+ },
+ "description": {
+ "type": "string",
+ "description": "Human-readable description of the concept"
+ },
+ "extends": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "minLength": 1
+ },
+ "uniqueItems": true,
+ "description": "Indicates that this concept extends one or more other concepts"
+ },
+ "derived_by": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Expression"
+ },
+ "uniqueItems": true,
+ "description": "Expressions that define how this concept is derived"
+ },
+ "identify_by": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "minLength": 1
+ },
+ "uniqueItems": true,
+ "description": "Names of relationships to use as the preferred identifier of this concept"
+ },
+ "requires": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Expression"
+ },
+ "uniqueItems": true,
+ "description": "Expressions that constrain the population of this concept"
+ },
+ "relationships": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Relationship"
+ },
+ "description": "Defines relationships that pertain primarily to the concept defined in this component"
+ },
+ "annotations": {
+ "$ref": "#/$defs/Annotations"
+ },
+ "iri": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Optional global identifier for this concept, expressed as a full IRI or as a QName (prefix:local) resolved against the ontology-level 'prefixes' map."
+ }
+ },
+ "required": ["concept", "type"],
+ "additionalProperties": false
+ },
+ "Expression": {
+ "type": "string",
+ "minLength": 1,
+ "description": "ANSI SQL expression"
+ },
+ "Relationship": {
+ "type": "object",
+ "description": "Relationship between concepts in the ontology",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Name of the relationship"
+ },
+ "description": {
+ "type": "string",
+ "description": "Human-readable description of the relationship"
+ },
+ "roles": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Role"
+ },
+ "description": "Additional roles in this relationship"
+ },
+ "multiplicity": {
+ "$ref": "#/$defs/Multiplicity"
+ },
+ "derived_by": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Expression"
+ },
+ "uniqueItems": true,
+ "description": "Expressions that define how this concept is derived"
+ },
+ "requires": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/Expression"
+ },
+ "uniqueItems": true,
+ "description": "Expressions that constrain the population of this relationship"
+ },
+ "verbalizes": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "minLength": 1
+ },
+ "uniqueItems": true,
+ "description": "Natural language expressions that verbalize this relationship"
+ },
+ "annotations": {
+ "$ref": "#/$defs/Annotations"
+ },
+ "iri": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Optional global identifier for this relationship, expressed as a full IRI or as a QName (prefix:local) resolved against the ontology-level 'prefixes' map."
+ }
+ },
+ "required": ["name", "verbalizes"],
+ "additionalProperties": false
+ },
+ "ConceptMapping": {
+ "type": "object",
+ "description": "Mappings from logical model constructs to some ontology component",
+ "properties": {
+ "concept": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Name of the concept whose part of the ontology we are mapping to"
+ },
+ "object_mappings": {
+ "type": "array",
+ "minItems": 1,
+ "items": {
+ "$ref": "#/$defs/ObjectMapping"
+ },
+ "description": "Mappings from logical constructs that populate the concept in this component. Valid only when the concept is an entity type"
+ },
+ "link_mappings": {
+ "type": "array",
+ "minItems": 1,
+ "items": {
+ "$ref": "#/$defs/LinkMapping"
+ },
+ "description": "Mappings from logical model relationships to ontology relationships pertaining to the mapped concept"
+ }
+ },
+ "required": ["concept"],
+ "anyOf": [{ "required": ["object_mappings"] }, { "required": ["link_mappings"] }],
+ "additionalProperties": false
+ },
+ "ConceptType": {
+ "type": "string",
+ "enum": [ "EntityType", "ValueType" ],
+ "description": "A concept is either an entity type or a value type"
+ },
+ "ReferentMapping": {
+ "type": "object",
+ "description": "Mapping from logical model constructs to a relationship used to references some entity type in the ontology",
+ "properties": {
+ "relationship": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Name of referent relationship"
+ },
+ "expression": {
+ "$ref": "#/$defs/Expression"
+ },
+ "referent_mappings": {
+ "type": "array",
+ "minItems": 1,
+ "items": {
+ "$ref": "#/$defs/ReferentMapping"
+ }
+ }
+ },
+ "required": ["relationship"],
+ "anyOf": [{ "required": ["expression"] }, { "required": ["referent_mappings"] }],
+ "additionalProperties": false
+ },
+ "Role": {
+ "type": "object",
+ "description": "Role in some relationship (the container)",
+ "properties": {
+ "concept": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Name of the concept playing this role"
+ },
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Optional name of this role, used when the same concept plays multiple roles in the same relationship"
+ },
+ "annotations": {
+ "$ref": "#/$defs/Annotations"
+ }
+ },
+ "required": ["concept"],
+ "additionalProperties": false
+ },
+ "ObjectMapping": {
+ "type": "object",
+ "description": "Pattern of logical-level expressions for identifying objects of some concept using the values in one or more fields",
+ "properties": {
+ "concept": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Name of the concept whose objects we are mapping to"
+ },
+ "referent_mappings": {
+ "type": "array",
+ "minItems": 1,
+ "items": {
+ "$ref": "#/$defs/ReferentMapping"
+ },
+ "description": "Maps logical-model constructs to referent relationships of this entity type"
+ },
+ "expression": {
+ "$ref": "#/$defs/Expression"
+ }
+ },
+ "anyOf": [{ "required": ["expression"] }, { "required": ["referent_mappings"] }],
+ "additionalProperties": false
+ },
+ "LinkMapping": {
+ "type": "object",
+ "description": "Mapping from logical schema to the links of relationships in the ontology",
+ "properties": {
+ "relationship": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Name of relationship being populated by this mapping node"
+ },
+ "object_mapping": {
+ "$ref": "#/$defs/ObjectMapping"
+ },
+ "children": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/LinkMapping"
+ },
+ "description": "Relationship maps at the next level in this hierarchy"
+ }
+ },
+ "required": ["object_mapping"],
+ "additionalProperties": false
+ },
+ "Multiplicity": {
+ "type": "string",
+ "enum": [ "ManyToOne", "OneToOne" ],
+ "description": "Relationship multiplicity"
+ },
+ "OntologyMap": {
+ "type": "object",
+ "description": "Map from the constructs of some logical model to some ontology",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Name of this ontology map"
+ },
+ "description": {
+ "type": "string",
+ "description": "Human-readable description of this ontology map"
+ },
+ "semantic_model": {
+ "$ref": "https://raw.githubusercontent.com/apache/ossie/main/core-spec/ossie-schema.json"
+ },
+ "concept_mappings": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/ConceptMapping"
+ },
+ "description": "Maps logical model constructs to some concept and its relationships in the ontology"
+ }
+ },
+ "required": ["semantic_model", "concept_mappings"],
+ "additionalProperties": false
+ }
+ }
+}
diff --git a/common/src/test/java/org/apache/gravitino/ontology/TestOssieOntologyDocuments.java b/common/src/test/java/org/apache/gravitino/ontology/TestOssieOntologyDocuments.java
new file mode 100644
index 0000000000..21dfa7e2e9
--- /dev/null
+++ b/common/src/test/java/org/apache/gravitino/ontology/TestOssieOntologyDocuments.java
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.ontology;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.Audit;
+import org.apache.gravitino.exceptions.IllegalOntologyException;
+import org.apache.gravitino.semantic.OssieDocument;
+import org.apache.gravitino.semantic.OssieFormat;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class TestOssieOntologyDocuments {
+
+ @Test
+ void testPinnedFlightsOntology() throws IOException {
+ OssieOntologyDocuments.ParsedOntology ontology =
+ OssieOntologyDocuments.importOntology(fixture("flights.ontology.yaml"));
+ Assertions.assertEquals("Flights", ontology.name());
+ Assertions.assertEquals(
+ OssieOntologyDocuments.DEFAULT_VERSION,
+ ontology.properties().get(OssieOntologyDocuments.VERSION_PROPERTY));
+ OntologyReferences.of(ontology.definition());
+ }
+
+ @Test
+ void testVersionAndOpaqueAnnotationsRoundTrip() {
+ OssieOntologyDocuments.ParsedOntology parsed =
+ OssieOntologyDocuments.importOntology(
+ OssieDocument.yaml(
+ "version: 0.3.0.dev9\nname: Example\n"
+ + "ai_context: {instructions: explanation}\n"
+ + "annotations: {identify_by: vendor, gravitino_properties: {team: analytics}}\n"
+ + "ontology: [{concept: Party, type: EntityType}]\n"));
+ Ontology ontology =
+ new CurrentOntology(
+ parsed.name(), parsed.comment(), parsed.definition(), parsed.properties());
+ OssieDocument json = OssieOntologyDocuments.exportOntology(ontology, OssieFormat.JSON);
+ OssieOntologyDocuments.ParsedOntology roundTrip = OssieOntologyDocuments.importOntology(json);
+ Assertions.assertEquals(parsed.definition(), roundTrip.definition());
+ Assertions.assertEquals(
+ Map.of("ossie-version", "0.3.0.dev9", "team", "analytics"), roundTrip.properties());
+ Assertions.assertEquals(
+ Map.of("identify_by", "vendor"), roundTrip.definition().fields().get("annotations"));
+ }
+
+ @Test
+ void testAnyNonBlankVersionIsAccepted() throws IOException {
+ // The vendored schemas relax the upstream root version constraint to minLength 1. Re-vendoring
+ // the upstream files without re-applying that change makes this test fail.
+ OssieOntologyDocuments.ParsedOntology ontology =
+ OssieOntologyDocuments.importOntology(withVersion(fixture("flights.ontology.yaml"), "1"));
+ Assertions.assertEquals(
+ "1", ontology.properties().get(OssieOntologyDocuments.VERSION_PROPERTY));
+ }
+
+ @Test
+ void testInvalidDocumentShape() {
+ IllegalOntologyException badRole =
+ Assertions.assertThrows(
+ IllegalOntologyException.class,
+ () ->
+ OssieOntologyDocuments.importOntology(
+ OssieDocument.yaml(
+ "version: dev\nname: Example\n"
+ + "ontology: [{concept: X, type: EntityType, relationships: [{name: r, verbalizes: []"
+ + ", roles: [{name: roleWithoutConcept}]}]}]\n")));
+ Assertions.assertTrue(badRole.getMessage().contains("$.ontology[0].relationships[0].roles[0]"));
+ Assertions.assertThrows(
+ IllegalOntologyException.class,
+ () ->
+ OssieOntologyDocuments.importOntology(
+ OssieDocument.yaml(
+ "version: dev\nname: Example\nontology_mappings: []\nontology: []\n")));
+ Assertions.assertThrows(
+ IllegalOntologyException.class,
+ () ->
+ OssieOntologyDocuments.importOntology(
+ OssieDocument.yaml(
+ "version: dev\nname: Example\nname: Duplicate\nontology: []\n")));
+ }
+
+ @Test
+ void testDefinitionCopiesCallerData() {
+ List<Map<String, String>> concepts = new ArrayList<>();
+ concepts.add(Map.of("concept", "Party", "type", "EntityType"));
+ OntologyDefinition definition = OntologyDefinition.of(Map.of("ontology", concepts));
+ concepts.clear();
+ Assertions.assertEquals(
+ List.of(Map.of("concept", "Party", "type", "EntityType")),
+ definition.fields().get("ontology"));
+ Assertions.assertThrows(UnsupportedOperationException.class, () -> definition.fields().clear());
+ }
+
+ @Test
+ void testInvalidInheritance() {
+ Assertions.assertThrows(
+ IllegalOntologyException.class,
+ () ->
+ OntologyReferences.of(
+ OntologyDefinition.of(
+ Map.of(
+ "ontology",
+ List.of(
+ Map.of(
+ "concept",
+ "Customer",
+ "type",
+ "EntityType",
+ "extends",
+ List.of("Party")),
+ Map.of(
+ "concept",
+ "Party",
+ "type",
+ "EntityType",
+ "extends",
+ List.of("Customer")))))));
+ }
+
+ @Test
+ void testIdentifyByUsesTheDeclaredRelationshipName() {
+ String ontology =
+ """
+ version: 0.3.0.dev0
+ name: Places
+ ontology:
+ - concept: Place
+ type: EntityType
+ relationships:
+ - name: geo.distance
+ roles: [{concept: Integer}]
+ verbalizes: [distance]
+ - concept: Airport
+ type: EntityType
+ extends: [Place]
+ identify_by: [%s]
+ """;
+ OntologyDefinition exactName =
+ OssieOntologyDocuments.importOntology(
+ OssieDocument.yaml(ontology.formatted("geo.distance")))
+ .definition();
+ OntologyReferences.of(exactName);
+
+ OntologyDefinition qualifiedName =
+ OssieOntologyDocuments.importOntology(
+ OssieDocument.yaml(ontology.formatted("Place.geo.distance")))
+ .definition();
+ IllegalOntologyException error =
+ Assertions.assertThrows(
+ IllegalOntologyException.class, () -> OntologyReferences.of(qualifiedName));
+ Assertions.assertTrue(error.getMessage().contains("$.ontology[1].identifyBy[0]"));
+ }
+
+ @Test
+ void testOntologyRoleNamesAndIdentifierArity() {
+ String ontology =
+ """
+ version: 0.3.0.dev0
+ name: Sales
+ ontology:
+ - concept: Customer
+ type: EntityType
+ identify_by: [%s]
+ relationships:
+ - name: parent
+ roles: [{concept: Customer%s}]
+ verbalizes: [parent]
+ - name: active
+ verbalizes: [active]
+ """;
+ OntologyReferences.of(
+ OssieOntologyDocuments.importOntology(
+ OssieDocument.yaml(ontology.formatted("parent", ", name: parent")))
+ .definition());
+ IllegalOntologyException duplicate =
+ Assertions.assertThrows(
+ IllegalOntologyException.class,
+ () ->
+ OntologyReferences.of(
+ OssieOntologyDocuments.importOntology(
+ OssieDocument.yaml(ontology.formatted("parent", "")))
+ .definition()));
+ Assertions.assertTrue(
+ duplicate.getMessage().contains("$.ontology[0].relationships[0].roles[0]"));
+ IllegalOntologyException nonBinary =
+ Assertions.assertThrows(
+ IllegalOntologyException.class,
+ () ->
+ OntologyReferences.of(
+ OssieOntologyDocuments.importOntology(
+ OssieDocument.yaml(ontology.formatted("active", ", name: parent")))
+ .definition()));
+ Assertions.assertTrue(nonBinary.getMessage().contains("$.ontology[0].identifyBy[0]"));
+ }
+
+ private static OssieDocument withVersion(OssieDocument document, String version) {
+ String content =
+ document.content().replaceFirst("(?m)^version: .*$", "version: \"" + version + "\"");
+ Assertions.assertNotEquals(document.content(), content);
+ return OssieDocument.yaml(content);
+ }
+
+ private static OssieDocument fixture(String name) throws IOException {
+ try (InputStream stream =
+ TestOssieOntologyDocuments.class.getResourceAsStream("/ossie/ontology/" + name)) {
+ return OssieDocument.yaml(new String(stream.readAllBytes(), StandardCharsets.UTF_8));
+ }
+ }
+
+ @SuppressWarnings("UnusedVariable")
+ private record CurrentOntology(
+ String name, String comment, OntologyDefinition definition, Map<String, String> properties)
+ implements Ontology {
+ @Override
+ public Audit auditInfo() {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/common/src/testFixtures/resources/ossie/ontology/flights.ontology.yaml b/common/src/testFixtures/resources/ossie/ontology/flights.ontology.yaml
new file mode 100644
index 0000000000..053e0fc66f
--- /dev/null
+++ b/common/src/testFixtures/resources/ossie/ontology/flights.ontology.yaml
@@ -0,0 +1,539 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+version: 0.3.0.dev0
+name: Flights
+description: Ontology of flights into and out of airports.
+requires:
+ - COUNT[Airport] > 0 # there must be at least one Airport
+ - COUNT[Carrier] > 0 # there must be at least one Carrier
+ontology:
+- concept: NrFeet
+ description: "Unit of measure for distance in feet"
+ type: ValueType
+ extends: [ Decimal ]
+- concept: NrPounds
+ description: "Unit of measure for weight in pounds"
+ type: ValueType
+ extends: [ Integer ]
+- concept: NrMiles
+ description: "Unit of measure for distance in miles"
+ type: ValueType
+ extends: [ Decimal ]
+- concept: NrMinutes
+ description: "Unit of measure for time in minutes"
+ type: ValueType
+ extends: [ Decimal ]
+- concept: CancelationCode
+ description: "The single character code that identifies the reason a flight is canceled"
+ type: ValueType
+ extends: [ String ]
+ requires: [ CancelationCode == 'A' OR CancelationCode == 'B' OR CancelationCode == 'C' OR CancelationCode == 'D' ]
+- concept: Capacity
+ description: "The capacity of an aircraft, measured in pounds."
+ type: ValueType
+ extends: [ NrPounds ]
+- concept: DegreesLatitude
+ type: ValueType
+ extends: [ Decimal ]
+ requires: [ DegreesLatitude <= 90, DegreesLatitude >= -90 ]
+- concept: DegreesLongitude
+ type: ValueType
+ extends: [ Decimal ]
+ requires: [ DegreesLongitude <= 180, DegreesLongitude >= -180 ]
+- concept: Polygon
+ description: "A polygon represented as a list of vertices, where each vertex is a pair of latitude and longitude coordinates."
+ type: ValueType
+ extends: [ String ]
+- concept: CityName
+ type: ValueType
+ extends: [ String ]
+- concept: Delay
+ type: ValueType
+ extends: [ NrMinutes ]
+- concept: Distance
+ type: ValueType
+ extends: [ NrMiles ]
+- concept: DistanceGroup
+ description: "A number used to group distances of different lengths, where 1 groups the shortest and 10 the longest."
+ type: ValueType
+ extends: [ Integer ]
+ requires: [ 1 <= DistanceGroup, DistanceGroup <= 10 ]
+- concept: RunwayGeometry
+ description: "A polygon that models the shape of a runway."
+ type: ValueType
+ extends: [ Polygon ]
+- concept: RunwayLength
+ description: "The unit for measuring the lengths of runways in American airports."
+ type: ValueType
+ extends: [ NrFeet ]
+- concept: RunwayDesignator
+ description: "Used to distinguish runways within a given airport."
+ type: ValueType
+ extends: [ String ]
+- concept: SerialNr
+ type: ValueType
+ extends: [ String ]
+- concept: StateCode
+ type: ValueType
+ extends: [ String ]
+- concept: StateName
+ type: ValueType
+ extends: [ String ]
+- concept: TailNr
+ type: ValueType
+ extends: [ String ]
+- concept: Year
+ type: ValueType
+ extends: [ String ]
+- concept: CancelationReason
+ description: "A curated set of reasons that explain why a flight is canceled"
+ type: EntityType
+ identify_by: [ code ]
+ relationships:
+ - name: code
+ roles:
+ - concept: CancelationCode
+ verbalizes: [ '{CancelationReason} is identified by {CancelationCode}']
+ multiplicity: OneToOne
+ - name: description
+ roles:
+ - concept: String
+ verbalizes: [ '{CancelationReason} has description- {String}' ] # The hyphen after "description" is significant when verbalizing constraints
+ multiplicity: ManyToOne # Each CancelationReason has at most one description String
+- concept: State
+ type: EntityType
+ identify_by: [ code ]
+ relationships:
+ - name: code
+ roles:
+ - concept: StateCode
+ verbalizes:
+ - '{State} is identified by {StateCode}'
+ multiplicity: OneToOne
+ - name: name
+ roles:
+ - concept: StateName
+ verbalizes:
+ - '{State} has {StateName}'
+ multiplicity: ManyToOne
+- concept: City
+ type: EntityType
+ identify_by: [ name, state ]
+ relationships:
+ - name: name
+ roles:
+ - concept: CityName
+ verbalizes:
+ - '{City} has {CityName}'
+ multiplicity: ManyToOne
+ - name: state
+ roles:
+ - concept: State
+ verbalizes:
+ - '{City} is located in {State}'
+ multiplicity: ManyToOne
+- concept: Runway
+ type: EntityType
+ identify_by: [ designator, airport ]
+ relationships:
+ - name: airport
+ roles:
+ - concept: Airport
+ verbalizes:
+ - '{Runway} belongs to {Airport}'
+ multiplicity: ManyToOne
+ - name: designator
+ roles:
+ - concept: RunwayDesignator
+ verbalizes:
+ - '{Runway} uses {RunwayDesignator}'
+ multiplicity: ManyToOne
+ - name: length
+ roles:
+ - concept: RunwayLength
+ verbalizes:
+ - '{Runway} has {RunwayLength}'
+ multiplicity: ManyToOne
+ - name: geometry
+ roles:
+ - concept: RunwayGeometry
+ verbalizes:
+ - '{Runway} has {RunwayGeometry}'
+ multiplicity: ManyToOne
+- concept: ManufacturerName
+ type: ValueType
+ extends: [ String ]
+- concept: Manufacturer
+ type: EntityType
+ identify_by: [ name ]
+ relationships:
+ - name: name
+ roles:
+ - concept: ManufacturerName
+ verbalizes:
+ - '{Manufacturer} is identified by {ManufacturerName}'
+ multiplicity: OneToOne
+- concept: ModelName
+ type: ValueType
+ extends: [ String ]
+- concept: Model
+ type: EntityType
+ identify_by: [ name, manufacturer ]
+ relationships:
+ - name: name
+ roles:
+ - concept: ModelName
+ verbalizes:
+ - '{Model} has {ModelName}'
+ multiplicity: ManyToOne
+ - name: manufacturer
+ roles:
+ - concept: Manufacturer
+ verbalizes:
+ - '{Model} is manufactured by {Manufacturer}'
+ multiplicity: ManyToOne
+- concept: Aircraft
+ type: EntityType
+ identify_by: [ tailnum ]
+ relationships:
+ - name: serial_number
+ roles:
+ - concept: SerialNr
+ verbalizes:
+ - '{Aircraft} has {SerialNr}'
+ multiplicity: ManyToOne
+ - name: name
+ roles:
+ - concept: String
+ verbalizes:
+ - '{Aircraft} has name {String}'
+ multiplicity: ManyToOne
+ - name: number_of_seats
+ roles:
+ - concept: Integer
+ verbalizes:
+ - '{Aircraft} has {Integer} seats'
+ multiplicity: ManyToOne
+ - name: tailnum
+ roles:
+ - concept: TailNr
+ verbalizes:
+ - '{Aircraft} is identified by {TailNr}'
+ multiplicity: OneToOne
+ - name: model
+ roles:
+ - concept: Model
+ verbalizes:
+ - '{Aircraft} has {Model}'
+ multiplicity: ManyToOne
+ - name: year_manufactured
+ roles:
+ - concept: Year
+ verbalizes:
+ - '{Aircraft} was manufactured in {Year}'
+ multiplicity: ManyToOne
+ - name: capacity
+ roles:
+ - concept: Capacity
+ verbalizes:
+ - '{Aircraft} has {Capacity}'
+ multiplicity: ManyToOne
+ - name: carrier
+ roles:
+ - concept: Carrier
+ verbalizes:
+ - '{Aircraft} is operated by {Carrier}'
+ multiplicity: ManyToOne
+- concept: AirportName
+ type: ValueType
+ extends: [ String ]
+- concept: AirportCode
+ description: "The three-letter IATA code for the airport."
+ type: ValueType
+ extends: [ String ]
+- concept: AirportId
+ description: "Five digit number used as an alternate identifier for airports."
+ type: ValueType
+ extends: [ String ]
+- concept: Airport
+ type: EntityType
+ identify_by: [ code ]
+ requires: [ Airport.latitude, Airport.longitude ]
+ relationships:
+ - name: city
+ roles:
+ - concept: City
+ verbalizes:
+ - '{Airport} is located in {City}'
+ multiplicity: ManyToOne
+ - name: serves
+ roles:
+ - concept: Market
+ verbalizes:
+ - '{Airport} serves {Market}'
+ multiplicity: ManyToOne
+ - name: average_departure_delay
+ roles:
+ - concept: Delay
+ verbalizes:
+ - '{Airport} has average- departure {Delay}' # The hyphen after "average" has significance when verbalizing constraints
+ multiplicity: ManyToOne # Each Airport has at most one average departure Delay
+ derived_by: [ 'Delay == AVG[Flight.departure_delay WHERE Airport == Flight.route.departure GROUP BY Airport]' ]
+ - name: longitude
+ roles:
+ - concept: DegreesLongitude
+ verbalizes:
+ - '{Airport} centers at {DegreesLongitude}'
+ multiplicity: ManyToOne
+ - name: average_arrival_delay
+ roles:
+ - concept: Delay
+ verbalizes:
+ - '{Airport} has average- arrival {Delay}' # The hyphen after "average" has significance when verbalizing constraints
+ multiplicity: ManyToOne # Each Airport has at most one average arrival Delay
+ derived_by: [ 'Delay == AVG[Flight.arrival_delay WHERE Airport == Flight.route.destination GROUP BY Airport]' ]
+ - name: name
+ roles:
+ - concept: AirportName
+ verbalizes:
+ - '{Airport} has {AirportName}'
+ multiplicity: ManyToOne
+ - name: code
+ roles:
+ - concept: AirportCode
+ verbalizes:
+ - '{Airport} has {AirportCode}'
+ multiplicity: OneToOne
+ - name: latitude
+ roles:
+ - concept: DegreesLatitude
+ verbalizes:
+ - '{Airport} centers at {DegreesLatitude}'
+ multiplicity: ManyToOne
+- concept: MarketName
+ type: ValueType
+ extends: [ String ]
+- concept: Market
+ type: EntityType
+ identify_by: [name]
+ relationships:
+ - name: name
+ roles: [ { concept: MarketName }]
+ verbalizes: [ '{Market} is identified by {MarketName}' ]
+ multiplicity: OneToOne
+- concept: FlightNr
+ description: "The IATA flight number, which is typically a combination of the airline's IATA code and a numeric code (e.g., 'AA1234')."
+ type: ValueType
+ extends: [ String ]
+- concept: FlightId
+ description: "A unique identifier for an instance of a flight"
+ type: ValueType
+ extends: [ String ]
+- concept: Flight
+ type: EntityType
+ identify_by: [ id ]
+ relationships:
+ - name: departure_delay
+ roles:
+ - concept: Delay
+ verbalizes:
+ - '{Flight} has departure- {Delay}' # The hyphen after "departure" has significance when verbalizing constraints
+ multiplicity: ManyToOne # Each Flight has at most one departure Delay
+ - name: number
+ roles:
+ - concept: FlightNr
+ verbalizes:
+ - '{Flight} has {FlightNr}'
+ multiplicity: ManyToOne
+ - name: scheduled_departure
+ roles: [ { concept: DateTime } ]
+ verbalizes:
+ - '{Flight} is scheduled to depart at {DateTime}'
+ multiplicity: ManyToOne
+ requires: [ Flight.scheduled_departure < Flight.scheduled_arrival ]
+ - name: arrival_delay
+ roles:
+ - concept: Delay
+ verbalizes:
+ - '{Flight} has arrival- {Delay}' # The hyphen after "arrival" has significance when verbalizing constraints
+ multiplicity: ManyToOne # Each Flight has at most one arrival Delay
+ - name: canceled
+ verbalizes:
+ - '{Flight} was canceled'
+ - name: canceled_due_to
+ roles:
+ - concept: CancelationReason
+ verbalizes:
+ - '{Flight} was canceled due to {CancelationReason}'
+ multiplicity: ManyToOne
+ - name: distance
+ roles:
+ - concept: Distance
+ verbalizes:
+ - '{Flight} spans actual- {Distance}' # The hyphen after "actual" has significance when verbalizing constraints
+ multiplicity: ManyToOne # Each Flight spans at most one actual Distance
+ - name: id
+ roles:
+ - concept: FlightId
+ verbalizes:
+ - '{Flight} is identified by {FlightId}'
+ multiplicity: OneToOne
+ - name: scheduled_arrival
+ roles:
+ - concept: DateTime
+ verbalizes:
+ - '{Flight} is scheduled to arrive at {DateTime}'
+ multiplicity: ManyToOne
+ - name: registers_longitude_series
+ roles:
+ - concept: DateTime
+ - concept: DegreesLongitude
+ verbalizes:
+ - '{Flight} at {DateTime} registers {DegreesLongitude}'
+ multiplicity: ManyToOne
+ - name: registers_latitude_series
+ roles:
+ - concept: DateTime
+ - concept: DegreesLatitude
+ verbalizes:
+ - '{Flight} at {DateTime} registers {DegreesLatitude}'
+ multiplicity: ManyToOne
+ - name: date
+ roles:
+ - concept: Date
+ verbalizes:
+ - '{Flight} is scheduled to depart on {Date}'
+ multiplicity: ManyToOne
+ - name: departs_at
+ roles:
+ - concept: DateTime
+ verbalizes:
+ - '{Flight} departs at {DateTime}'
+ multiplicity: ManyToOne
+ requires: [ Flight.departs_at < Flight.arrives_at ]
+ - name: diverted
+ verbalizes:
+ - '{Flight} was diverted'
+ - name: arrives_at
+ roles:
+ - concept: DateTime
+ verbalizes:
+ - '{Flight} arrives at {DateTime}'
+ multiplicity: ManyToOne
+ - name: route
+ roles:
+ - concept: Route
+ verbalizes:
+ - '{Flight} traverses {Route}'
+ multiplicity: ManyToOne
+ - name: aircraft
+ roles:
+ - concept: Aircraft
+ verbalizes:
+ - '{Flight} uses {Aircraft}'
+ multiplicity: ManyToOne
+ requires: [ Flight.operated_by(Aircraft.carrier) ]
+ - name: operated_by
+ roles:
+ - concept: Carrier
+ verbalizes:
+ - '{Flight} is operated by {Carrier}'
+ multiplicity: ManyToOne
+- concept: CarrierCode
+ description: "The two-letter IATA code for the airline carrier."
+ type: ValueType
+ extends: [ String ]
+- concept: CarrierName
+ type: ValueType
+ extends: [ String ]
+- concept: Carrier
+ type: EntityType
+ identify_by: [ code ]
+ relationships:
+ - name: code
+ roles:
+ - concept: CarrierCode
+ verbalizes:
+ - '{Carrier} uses {CarrierCode}'
+ multiplicity: OneToOne
+ - name: name
+ roles:
+ - concept: CarrierName
+ verbalizes:
+ - '{Carrier} has {CarrierName}'
+ multiplicity: ManyToOne
+- concept: RouteId
+ type: ValueType
+ description: "A unique identifier for a route between two airports. Constructed by concatenating the IATA codes of the departure and destination airports (e.g., 'ATL -> DCA')"
+ extends: [ String ]
+- concept: Route
+ type: EntityType
+ identify_by: [ id ]
+ relationships:
+ - name: average_departure_delay
+ roles:
+ - concept: Delay
+ verbalizes:
+ - '{Route} has average- departure {Delay}' # The hyphen after "average" has significance when verbalizing constraints
+ multiplicity: ManyToOne # Each Route has at most one average departure Delay
+ derived_by: [ 'Delay == AVG[Flight.departure_delay WHERE Flight.route(Route) GROUP BY Route]' ]
+ - name: average_arrival_delay
+ roles:
+ - concept: Delay
+ verbalizes:
+ - '{Route} has average- arrival {Delay}' # The hyphen after "average" has significance when verbalizing constraints
+ multiplicity: ManyToOne # Each Route has at most one average arrival Delay
+ derived_by: [ 'Delay == AVG[Flight.arrival_delay WHERE Flight.route(Route) GROUP BY Route]' ]
+ - name: distance
+ roles:
+ - concept: Distance
+ verbalizes:
+ - '{Route} spans {Distance}'
+ multiplicity: ManyToOne
+ - name: lies_in
+ roles:
+ - concept: DistanceGroup
+ verbalizes:
+ - '{Route} has {DistanceGroup}'
+ multiplicity: ManyToOne
+ - name: id
+ roles:
+ - concept: RouteId
+ verbalizes:
+ - '{Route} is identified by {RouteId}'
+ multiplicity: OneToOne
+ - name: route_name
+ roles:
+ - concept: String
+ verbalizes:
+ - '{Route} has name- {String}' # The hyphen after "name" has significance when verbalizing constraints
+ multiplicity: ManyToOne
+ - name: destination
+ roles:
+ - concept: Airport
+ verbalizes:
+ - '{Route} connects to destination- {Airport}' # The hyphen after "destination" has significance when verbalizing constraints
+ multiplicity: ManyToOne # Each Route connects to at most one destination Airport
+ requires: [ 'NOT Route.departure(Airport)' ]
+ - name: departure
+ roles:
+ - concept: Airport
+ verbalizes:
+ - '{Route} connects to departure- {Airport}' # The hyphen after "departure" has significance when verbalizing constraints
+ multiplicity: ManyToOne # Each Route connects to at most one departure Airport
+ requires: [ 'NOT Route.destination(Airport)' ]
diff --git a/core/build.gradle.kts b/core/build.gradle.kts
index 8695e1117a..181a31efbd 100644
--- a/core/build.gradle.kts
+++ b/core/build.gradle.kts
@@ -55,6 +55,11 @@ dependencies {
implementation(libs.h2db)
implementation(libs.jackson.databind)
implementation(libs.jackson.dataformat.yaml)
+ implementation(libs.json.schema.validator) {
+ // Use the Jackson versions already supplied by Gravitino's distribution.
+ exclude(group = "com.fasterxml.jackson.core", module = "jackson-databind")
+ exclude(group = "com.fasterxml.jackson.dataformat", module = "jackson-dataformat-yaml")
+ }
implementation(libs.jackson.jaxrs.json.provider) // This is required by lance
implementation(libs.lance) {
exclude(group = "com.fasterxml.jackson.core", module = "*") // provided by gravitino
diff --git a/dev/release/maven/NOTICE.ossie b/dev/release/maven/NOTICE.ossie
new file mode 100644
index 0000000000..87704996c5
--- /dev/null
+++ b/dev/release/maven/NOTICE.ossie
@@ -0,0 +1,2 @@
+Apache Ossie (incubating)
+Copyright 2026 The Apache Software Foundation
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 4b3b515eb0..2fd29cdc72 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -239,6 +239,7 @@ reactor-netty-http = {group = "io.projectreactor.netty", name = "reactor-netty-h
reactor-netty-core = {group = "io.projectreactor.netty", name = "reactor-netty-core", version.ref = "reactor-netty-core"}
jackson-bom-v218 = { group = "com.fasterxml.jackson", name = "jackson-bom", version.ref = "jackson218" }
jackson-bom-v221 = { group = "com.fasterxml.jackson", name = "jackson-bom", version.ref = "jackson221" }
+json-schema-validator = { group = "com.networknt", name = "json-schema-validator", version = "1.5.9" }
jackson-databind = { group = "com.fasterxml.jackson.core", name = "jackson-databind", version.ref = "jackson" }
jackson-annotations = { group = "com.fasterxml.jackson.core", name = "jackson-annotations", version.ref = "jackson" }
jackson-datatype-jdk8 = { group = "com.fasterxml.jackson.datatype", name = "jackson-datatype-jdk8", version.ref = "jackson" }