Arquisoft / viadeSpec

Viade Data Model Specification
https://arquisoft.github.io/viadeSpec/
MIT License
7 stars 1 forks source link

Creation of a dependency to hold the defined route context/base template info #31

Open fincamd opened 4 years ago

fincamd commented 4 years ago

One thing came to my mind after reading @luispc1998 proposal on #22.

I have realised (as many of you surely) that such proposal's route files written in JSON-LD have to include the "@context" key with a specific value.

As it is something that is constant to all files following such pattern, I came with the idea of centralising that "@context" object into some sort of package/class/object/function thing, defining it as a dependency (say on npm for instance) associated with this repo/standard definition and using it from the apps that need it.

The reason for this is to avoid hardcoding such potentially living thing as this document is. This would mean that whenever this standard evolves, so does the files produced by the applications using this resource. The only thing needed would be to update the dependency.

Although I don't have a clue on how this can be done yet, I will try to conduct a little research on the matter see if I can find something.

fincamd commented 4 years ago

I think this idea could be extended to the full base template for a route file inlcuding name, description, points, etc.

labra commented 4 years ago

Do you mean creating a dereferentiabe context file in this project?

It seems ok for me, could you create a draft proposal in a Pull request?

fincamd commented 4 years ago

I have been thinking about this for a little now and this is what I ment at the very beginning:

{
    "@context": {
        "@version": 1.1,
        "comments": {
            "@container": "@list",
            "@id": "viade:comments"
        },
        "description": {
            "@id": "schema:description",
            "@type": "xs:string"
        },
        "media": {
            "@container": "@list",
            "@id": "viade:media"
        },
        "name": {
            "@id": "schema:name",
            "@type": "xs:string"
        },
        "points": {
            "@container": "@list",
            "@id": "viade:points"
        },
        "latitude": {
            "@id": "schema:latitude",
            "@type": "xs:double"
        },
        "longitude": {
            "@id": "schema:longitude",
            "@type": "xs:double"
        },
        "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "schema": "http://schema.org/",
        "viade": "http://arquisoft.github.io/viadeSpec/",
        "xsd": "http://www.w3.org/2001/XMLSchema#"
    },
    "comments": [],
    "media": [],
    "name": ,
    "description": ,
    "points":
}

This file would be uploaded inside the repo for the applications to fetch with an URI. Then it would be parsed into memory and the generated object could be updated with data obtained from our applications. Then this object is serialized again using JSON.stringify(...) function to be saved to a json file. From here it can be uploaded to the POD or saved in the user's computer. Here is a sample of its usage:

modifyFromJsonLd(stringData) {
    let parsedRoute = JSON.parse(stringData);
    parsedRoute["name"] = this.name;
    parsedRoute["description"] = this.description;
    parsedRoute["points"] = processPoints(this.points);
        return JSON.stringify(parsedRoute);
}

Where parameter stringData is the data read from the file.

Please, should there be anything unclear, let me know so I can provide further examples.

fincamd commented 4 years ago

It is taken for granted that if some other piece of information is needed, it can be appended to the object with a simple dictionary key access while leaving the standard route template untouched.

parsedRoute["extraInfo"] = this.extraInfo;