Skip to content

Commit

Permalink
feat (modl): Initial outline of Files & Folders model
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Jun 26, 2024
1 parent eeedb6c commit c86ce6f
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/concepts/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ or something like [Amazon Ion](https://amazon-ion.github.io/ion-docs/) or [other

## Schemas

Enola currently uses [Proto 3](https://protobuf.dev/programming-guides/proto3/) as its
Enola currently uses [RDFS](../models/example.org/class.md) and (TBD) [Proto 3](https://protobuf.dev/programming-guides/proto3/) as its
Schema language. It is conceptually open to supporting other kinds of schemas in the future; perhaps e.g.
[JSON Schema](https://github.com/enola-dev/enola/issues/313), or [Capโ€™n Proto](https://capnproto.org/language.html), or [TypeScript](https://www.typescriptlang.org/docs/handbook/2/objects.html) (ร  la [Typson](https://github.com/lbovet/typson)), or [XML Schema](https://en.wikipedia.org/wiki/XML_Schema_(W3C)) (XSD), or [YANG](https://en.wikipedia.org/wiki/YANG) or [FHIR](https://www.hl7.org/fhir/) or [Varlink](https://varlink.org/Interface-Definition) or [Web IDL](https://webidl.spec.whatwg.org) or
[ASN.1](https://en.m.wikipedia.org/wiki/ASN.1) or [GNU poke](https://www.gnu.org/software/poke/).
1 change: 1 addition & 0 deletions java/dev/enola/thing/gen/Relativizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public static URI dropSchemeAddExtension(String iri, String extension) {
return dropSchemeAddExtension(URI.create(Templates.dropVariableMarkers(iri)), extension);
}

// skipcq: JAVA-R1000 TODO Simplify this overly complex function!
public static URI dropSchemeAddExtension(final URI thingIRI, final String extension) {
var scheme = thingIRI.getScheme();
if (scheme == null) return thingIRI;
Expand Down
4 changes: 4 additions & 0 deletions java/dev/enola/thing/gen/markdown/MarkdownSiteGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public void generate(
var outputIRI = base.resolve(relativeThingIRI);
LOG.info("Generating (base={}, thingIRI={}): {}", base, thingIRI, outputIRI);
var outputResource = rp.getWritableResource(outputIRI);
if (outputResource == null) {
LOG.error("ResourceProvider cannot provide a WritableResource: {}", outputIRI);
continue;
}
try (var writer = outputResource.charSink().openBufferedStream()) {
var meta =
mtg.generate(thing, writer, outputIRI, base, isDocumentedIRI, ts, footer);
Expand Down
71 changes: 71 additions & 0 deletions models/enola.dev/files.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@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: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: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:range xsd:unsignedLong; # TODO Use a Datatype which permits KiB/MB etc. (from UoM?)
rdfs:domain enola:File.

enola:MediaType a rdfs:Datatype;
rdfs:comment "Internet Media Type, also known as a MIME Type or Content Type.";
enola:rfc "6838";
rdfs:subClassOf xsd:token.

enola:mediaType a rdf:Property;
rdfs:range enola:MediaType;
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.".
21 changes: 21 additions & 0 deletions models/enola.dev/java.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@prefix enola: <https://enola.dev/>.
@prefix enolaj: <https://enola.dev/java/>.
@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#>.

enolaj:type a rdfs:Class;
schema:name "Java Type";
schema:description "Type (Class, Interface, Enum, Record, Primitive, Array, Void) in the Java Virtual Machine (JVM).";
enola:example "https://enola.dev/java/type/java.lang.Object";
enola:iriTemplate "https://enola.dev/java/type/{FQN}";
# TODO JavaDoc site base URI should be configurable via some sort of global variable
enola:javaDoc "https://docs.oracle.com/en/java/javase/21/docs/api/{MODULE | DotToSlash }/{FQN | DotToSlash }.html"^^enola:Template;
enola:emoji "โ˜•".

enolaj:module a rdfs:Class;
schema:name "Java Module";
enola:example "https://enola.dev/java/module/java.base";
enola:iriTemplate "https://enola.dev/java/module/{FQN}";
enola:emoji "๐Ÿ“ฆ".
12 changes: 12 additions & 0 deletions models/enola.dev/linux.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@prefix enola: <https://enola.dev/>.
@prefix lenola: <https://enola.dev/linux/>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@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#>.

lenola:ontology a owl:Ontology;
rdfs:label "An Ontology by Enola.dev about Linux related concepts.".

lenola:Machine a rdfs:Class;
enola:emoji "๐Ÿ–ฅ๏ธ".
88 changes: 65 additions & 23 deletions models/enola.dev/properties.ttl
Original file line number Diff line number Diff line change
@@ -1,17 +1,80 @@
@prefix enola: <https://enola.dev/>.
@prefix enolay: <https://enola.dev/yaml/>.
@prefix enolaj: <https://enola.dev/java/>.
@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:ontology a owl:Ontology;
rdfs:label "Enola.dev's base/core Ontology.".

enola:Embedded a rdfs:Class;
rdfs:comment "Parent (abstract) Class for things which have no IRI identity of their own and which thus should only ever appear in 'RDF blank nodes'. (Like owl:hasValue _:bNode on an owl:DatatypeProperty; without OWL dependency. Or like a sh:nodeKind sh:BlankNode SHACL shape.)".

# NOT enola:Timestamped a rdfs:Class;

enola:Event a rdfs:Class;
rdfs:comment "Parent (abstract) Class for anything which happened at the specified #timestamp dateTime.".

enola:timestamp a rdf:Property;
rdfs:range xsd:dateTime;
rdfs:domain enola:Event;
rdfs:comment "Instant at which this happened.";
enola:emoji "๐Ÿ•‘".

enola:TimeIntervaled a rdfs:Class;
rdfs:comment "Parent (abstract) Class for anything which has a start & end #timestamp dateTime.".

enola:startedAt a rdf:Property;
rdfs:subPropertyOf enola:timestamp;
rdfs:domain enola:TimeIntervaled.

enola:endedAt a rdf:Property;
rdfs:subPropertyOf enola:timestamp;
rdfs:domain enola:TimeIntervaled.

enola:createdAt a rdf:Property;
rdfs:subPropertyOf enola:timestamp;
rdfs:domain enola:File.

enola:modifiedAt a rdf:Property;
rdfs:subPropertyOf enola:timestamp;
rdfs:domain enola:File.

enola:Hardware a rdfs:Class;
rdfs:comment "Parent (abstract) Class for 'hard ware', i.e. 'physical computer stuff' - you can touch this!";
enola:wikipedia "Computer_hardware". # https://en.wikipedia.org/wiki/Computer_hardware

enola:Software a rdfs:Class;
rdfs:comment "Parent (abstract) Class for 'soft ware', i.e. 'virtual computer stuff' - you can think of but cannot physically touch this.";
enola:wikipedia "Software". # https://en.wikipedia.org/wiki/Software

enola:SoftwareWithURL a rdfs:Class;
rdfs:subClassOf enola:Software;
rdfs:comment "Parent (abstract) Class for a piece of [[Software]] which has a URL that you can type into a web browser to look at (the UI of) it.".

# TODO Fix https://github.com/enola-dev/enola/pull/735 and un-comment this:
# TODO Discuss with someone smart if this is a good idea? Given "Open World" assumption, this seems "fair game" - hopefully?
# schema:url schema:domainIncludes enola:SoftwareWithURL.

enola:emoji a rdf:Property;
schema:name "Emoji";
rdfs:range xsd:string;
schema:description "Emoji ๐Ÿ˜ƒ of a Thing, from Unicode or <a href='https://www.nerdfonts.com'>Nerdfonts</a>.";
enola:emoji "๐Ÿ˜ƒ".

enola:parent a rdf:Property;
rdfs:range schema:Thing;
rdfs:comment "A 'hierarchical' parent. This is typically subclassed - and thus there could be several different kinds of parents. Similar to https://schema.org/isPartOf; but that's specific to CreativeWork, while this is not.".

# Similar to https://schema.org/hasPart; but that's specific to CreativeWork, this is not
enola:children a rdf:Property;
schema:inverseOf enola:parent.

# TODO schema:source?
# TODO Rename origin to origins, because the Statements of one Thing could come from various places.
enola:origin a rdf:Property;
schema:name "Origin";
rdfs:range xsd:anyURI;
Expand All @@ -20,13 +83,15 @@ enola:origin a rdf:Property;

# TODO Split Q & P...
enola:wikidata a rdf:Property;
# TODO This, and other, images should be a String, not a link, and the UI needs to be coded to handle it... validate!
schema:image <https://upload.wikimedia.org/wikipedia/commons/f/ff/Wikidata-logo.svg>;
# https://www.wikidata.org/wiki/Wikidata:Data_access#Linked_Data_Interface_(URI)
schema:url "http://www.wikidata.org/entity/{VALUE}"^^enola:IRITemplate;
schema:description "Wikidata Q123 or P123 etc.".
# TODO Range (?) is a RegExp like [QP][0-9]+ or so...

enola:wikipedia a rdf:Property;
# TODO This, and other, images should be a String, not a link, and the UI needs to be coded to handle it... validate!
schema:image <https://upload.wikimedia.org/wikipedia/commons/8/80/Wikipedia-logo-v2.svg>;
schema:description "Wikipedia EN page ID (not URL), e.g. 'Wikipedia' (for https://en.wikipedia.org/wiki/Wikipedia)";
schema:url "https://en.wikipedia.org/wiki/{VALUE}"^^enola:IRITemplate.
Expand Down Expand Up @@ -68,26 +133,3 @@ enola:GKG a rdfs:Datatype;
enola:rfc a rdf:Property;
rdfs:range xsd:positiveInteger;
schema:url "https://datatracker.ietf.org/doc/rfc{VALUE}"^^enola:IRITemplate.

enolaj:type a rdfs:Class;
schema:name "Java Type";
schema:description "Type (Class, Interface, Enum, Record, Primitive, Array, Void) in the Java Virtual Machine (JVM).";
enola:example "https://enola.dev/java/type/java.lang.Object";
enola:iriTemplate "https://enola.dev/java/type/{FQN}";
# TODO JavaDoc site base URI should be configurable via some sort of global variable
enola:javaDoc "https://docs.oracle.com/en/java/javase/21/docs/api/{MODULE | DotToSlash }/{FQN | DotToSlash }.html"^^enola:Template;
enola:emoji "โ˜•".

enolaj:module a rdfs:Class;
schema:name "Java Module";
enola:example "https://enola.dev/java/module/java.base";
enola:iriTemplate "https://enola.dev/java/module/{FQN}";
enola:emoji "๐Ÿ“ฆ".

enolay:uri a rdf:Property;
rdfs:range xsd:anyURI;
schema:description "The URI of a YAML `!!Tag` Type; see e.g. https://yaml.org/type/.".

enolay:shorthand a rdf:Property;