# SPDX-License-Identifier: Apache-2.0
#
# Copyright 2024-2026 The Enola <https://enola.dev> Authors
#
# Licensed 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
#
#     https://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.

# TODO Remove this once we can generate it from files.esch.yaml

@prefix enola:  <https://enola.dev/>.
@prefix owl:    <http://www.w3.org/2002/07/owl#>.
@prefix schema: <https://schema.org/>.
@prefix rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs:   <http://www.w3.org/2000/01/rdf-schema#>.
@prefix xsd:    <http://www.w3.org/2001/XMLSchema#>.

enola:fileOntology a owl:Ontology;
  rdfs:label "An Ontology by Enola.dev about Files on Computers.".

enola:File a rdfs:Class;
  rdfs:comment "File holds [[Data]], identified by a [[Path]] on a [[Filesystem]], with a [[MediaType]].";
  rdfs:isDefinedBy enola:fileOntology;
  rdfs:subClassOf enola:SoftwareWithURL;
  enola:example <https://enola.dev/file/localhost/tmp/example.txt>;
  enola:iriTemplate "https://enola.dev/file/{FILESYSTEM}/{PATH}";
  enola:filesystem "fs:{FILESYSTEM}"^^enola:IRITemplate;
  # TODO https://github.com/enola-dev/enola/issues/739
  # enola:path "{PATH}"^^enola:IRITemplate; # ^^enola:Template ??
  enola:wikipedia "Computer_file"; # https://en.wikipedia.org/wiki/Computer_file
  enola:emoji "🗎".

enola:Folder a rdfs:Class;
  rdfs:comment "Folder is a [[Container]] of other Folders and [[File]]s";
  rdfs:subClassOf enola:SoftwareWithURL;
  enola:wikipedia "Directory_(computing)"; # https://en.wikipedia.org/wiki/Directory_(computing)
  enola:emoji "📁".

enola:parentFolder a rdf:Property;
  rdfs:subPropertyOf enola:parent;
  rdfs:range enola:Folder;
  rdfs:domain enola:File, enola:Folder;
  rdfs:comment "Parent Folder which this File or Folder is in".

enola:Filesystem a rdfs:Class.

enola:LocalhostRootFilesystem a rdfs:Class;
  rdfs:subClassOf enola:Filesystem;
  rdfs:comment "The Class of the (single) Filesystem serving / on localhost.".

enola:filesystem a rdf:Property;
  rdfs:range enola:Filesystem;
  rdfs:domain enola:File.

enola:path a rdf:Property;
  rdfs:range xsd:string;
  rdfs:domain enola:File.

enola:size a rdf:Property;
  rdfs:comment "Number of bytes of data.";
  rdfs:range xsd:unsignedLong; # TODO Use a Datatype which permits KiB/MB etc. (from UoM?)
  rdfs:domain enola:File.

<https://enola.dev/file/localhost/tmp/example.txt> a enola:File;
  schema:url "file://localhost/tmp/example.txt";
  # Automagic: enola:path "/tmp/example.txt";
  # Automagic: enola:filesystem <localhost>;
  enola:size "123"^^xsd:unsignedLong;
  enola:createdAt "2024-05-12T18:58:02.123+00:00"^^xsd:dateTime;
  enola:modifiedAt "2024-06-07T22:17:02.123+00:00"^^xsd:dateTime;
  enola:mediaType "text/plain;charset=UTF-8";
.

<fs:localhost> a enola:LocalhostRootFilesystem;
  rdfs:comment "The Filesystem serving / on localhost.".
