Usage
Basic description of how to use the tool.
The DCH model construction tool takes a zip file containing a set of Comma Separated Values (CSV) files describing what to create and returns a zip file containing a set of generated model files (in the form of turtle files) along with feedback of the construction process.
To use it you upload a zip file and hit the Generate Model button. Generation of models takes some time, depending on complexity, from seconds or ten's of seconds through to a minute or two. When the tool is finished the web page lets you know and automatically downloads a zip file containing the results. The results can be manually downloaded if the automatic download does not occur.
The tool is available under the Tools menu on the LHS of the DCH Web interface: Tools -> Generate Model(s).
Inputs
The provided zip file has some required components as well as some optional components.
input_archive.zip
├─ input_csvs/ (*)
│ ├─ objects.csv
│ ├─ skeleton.csv
│ ├─ point_linkage.csv
│ └─ point_list.csv
├─ input_ttls/
│ ├─ site.ttl
│ └─ building.ttl
└─ manifest.json (*)
// (*) denotes required content
Required contents:
at the top level in the zip file, you need to have a
manifest.jsontext file.at the top level in the zip file, you need to have a folder called
input_csvswith at least one CSV file. In this example, four CSV files have been provided:objects.csvfor the CREATE operationskeleton.csvfor the RELATE operation, andpoint_linkage.csvalong withpoint_list.csvfor the POINT_CREATE_LINK_PATTERN_MATCH operation
Optional contents:
you can provide some starting models (turtle files) in an
input_ttlsfolder. In this example, bothsite.ttlandbuilding.ttlhave been provided as existing models for a site and building respectively. For more information about extending existing models, see the following page:
The Manifest file
The manifest file is defined within manifest.json, and provides two inputs to the model generation tooling:
id_mapping: a mapping from a human-readable identifier of the model to the Universal Resource Identifiers (URIs) to use when constructing models.operations: The set of operations to perform and any configuration parameters for each operation (at a minimum the specific csv file(s) to use as the input to the operation). It is possible to run operations in any order and/or to run the same operation multiple times with different input csvs/configurations). Running an operation multiple times with different input CSVs is a desirable way to prevent the input csv's form getting large and difficult to comprehend.
ID Mapping
As indicated, URIs are used in the turtle files to refer to different models. DCH URIs take the following forms:
<dch:org/[org_id]/site/[site_id]#> # URI for a site
<dch:org/[org_id]/site/[site_id]/building/[building_id]#> # URI for a buildingTo make the input CSVs for the model construction tools as simple and as readable as possible these longer URIs are not used in those files, but rather simpler model_id prefixes are used in the CSVs to identify which models things should be created in.
These prefixes always become the filenames for the output turtle files.
There are two alternate mechanisms used to set the URI that is used for each model_id used in the csv's. The first mechanism is that the manifest file can contain an id_mapping component that instructs the model construction tools how to map the model_id's used in the input csvs to the desired URIs in the output files. The alternative mechanism is based on the optional ability to provide a starting set of models (in turtle format) files to the model construction tool. When that is done, the mapping from model_id to URI can be determined from the contents of the provided turtle file(s) file. If a mapping cannot be derived from either the manifest or a provided input turtle file, then a default URI will be used, and a warning provided.
Do not provide different mappings in the Manifest file and in an input turtle files, as that will cause contention and provide undesired outputs.
It is highly recommended that the id_mapping be provided in the manifest file, as being explicit provides an extra level of quality control over potential typos or mistakes in input csvs.
Operations
As indicated, there are three operations that can be performed by the model construction code. Details are in the following sections. You specify which operations to execute in which order along with configuration details in the manifest file. At least one operation must be specified.
In the manifest file the three operations are defined as:
CREATE
RELATE
POINT_CREATE_LINK_PATTERN_MATCH
A full example manifest file that invokes all operations is below. Note the order that operations are specified in the file is the order they get executed. Also operations can be specified multiple times (with different configurations/input files). Ordering is important as some operations require things to already exist in the models (from previous operations):
{
"manifest_version": "1.0.0",
"id_mapping": {
"csiro_hobart_site": "dch:org/csiro/site/csiro_hobart",
"csiro_hobart_B001": "dch:org/csiro/site/csiro_hobart/building/building001",
"csiro_hobart_B002": "dch:org/csiro/site/csiro_hobart/building/building002",
"csiro_hobart_B003": "dch:org/csiro/site/csiro_hobart/building/building003",
"csiro_hobart_B004": "dch:org/csiro/site/csiro_hobart/building/building004",
"csiro_hobart_B005": "dch:org/csiro/site/csiro_hobart/building/building005"
},
"operations": [
{
"operation_type": "CREATE",
"config": {
"object_file": "csiro_hobart_objects.csv"
}
},
{
"operation_type": "RELATE",
"config": {
"skeleton_file": "csiro_hobart_skeleton.csv"
}
},
{
"operation_type": "POINT_CREATE_LINK_PATTERN_MATCH",
"config": {
"point_linkage_file": "csiro_hobart_point_linkage.csv",
"point_list_file": "csiro_hobart_point_list.csv"
}
}
]
}Input CSVs
The CSVs used within the input archive will differ depending on which operations are configured for the tool to run. For additional information and input CSV examples can be found within the following pages:
CREATE operation
RELATE operation
POINT_CREATE_LINK_PATTERN_MATCH operation
Outputs
The output zip file will contain:
output_archive.zip
├─ mgtool.log (*)
├─ site.ttl
├─ building.ttl
└─ mysite_point_linkage_point_create_link_pattern_match_operation_report.csvone or more turtle files (.ttl files) of the generated model(s)
a mgtool.log file that contains information, warnings and errors encountered when processing your supplied information.
optionally, depending on whether any of the pattern matching operations of the model construction tool were used, some *_report.csv files that provide further details around what the tooling did when generating your models. In this case,
mysite_point_linkage_point_create_link_pattern_match_operation_report.csv.
Examples
Example 1: No URI mapping provided; defaults used
Inputs
{
"manifest_version": "1.0.0",
"operations": [
{
"operation_type": "CREATE",
"config": {
"object_file": "objects.csv"
}
}
]
}input_csvs/objects.csv
(Csv file referred to in the manifest and provided in the input_csv's folder for the Create Operation to use).
mySiteModel|siteName
Site
myBuildingModel|buildingName
Building
Outputs
Zipping those up and running that through the tool cause the tool to provide default URIs as there is no id_mapping specified in the manifest file, nor any input turtle files were provided. The tool will produce two turtle output files:
@prefix brick: <https://brickschema.org/schema/Brick#> .
@prefix mySiteModel: <dch:org/csiro/site/mySiteModel#> .
mySiteModel:siteName a brick:Site ;
brick:keyValue [ brick:key "mgtool" ;
brick:value "version: 2.0" ],
[ brick:key "mgtool" ;
brick:value "build date: 2024-04-08" ] .@prefix brick: <https://brickschema.org/schema/Brick#> .
@prefix myBuildingModel: <dch:org/csiro/site/mySiteModel/building/myBuildingModel#> .
myBuildingModel:buildingName a brick:Building ;
brick:keyValue [ brick:key "mgtool" ;
brick:value "version: 2.0" ],
[ brick:key "mgtool" ;
brick:value "build date: 2024-04-08" ] .And the log file will include the following warnings:
WARNING | No URI was mapped to site model_id 'mySiteModel' (from manifest or input ttl files), using a default.
WARNING | No URI was mapped to building model_id 'myBuildingModel' (from manifest or input ttl files), using a default.
Example 2: Providing an id_mapping in the manifest to specify the desired URIs
Inputs
{
"manifest_version": "1.0.0",
"id_mapping": {
"mySiteModel": "dch:org/documentation/site/Usage_Eg2_Hobart_Waterfront_Hotel#",
"myBuildingModel": "dch:org/documentation/site/Usage_Eg2_Hobart_Waterfront_Hotel/building/restaurant_eg2#"
},
"operations": [
{
"operation_type": "CREATE",
"config": {
"object_file": "objects.csv"
}
}
]
}input_csvs/objects.csv
mySiteModel|siteName
Site
myBuildingModel|buildingName
Building
Outputs
In this case running the tool will produce the following turtle files (without the log file warnings):
@prefix brick: <https://brickschema.org/schema/Brick#> .
@prefix mySiteModel: <dch:org/documentation/site/Usage_Eg2_Hobart_Waterfront_Hotel#> .
mySiteModel:siteName a brick:Site ;
brick:keyValue [ brick:key "mgtool" ;
brick:value "version: 2.0" ],
[ brick:key "mgtool" ;
brick:value "build date: 2024-04-08" ] .@prefix brick: <https://brickschema.org/schema/Brick#> .
@prefix myBuildingModel: <dch:org/documentation/site/Usage_Eg2_Hobart_Waterfront_Hotel/building/restaurant_eg2#> .
myBuildingModel:buildingName a brick:Building ;
brick:keyValue [ brick:key "mgtool" ;
brick:value "version: 2.0" ],
[ brick:key "mgtool" ;
brick:value "build date: 2024-04-08" ] .Example 3: Providing URI mappings via a input turtle file(s)
Inputs
Using the same manifest and objects.csv file as Example 1, but also providing the following input turtle files in a input_ttls folder in the provided zip file:
@prefix brick: <https://brickschema.org/schema/Brick#> .
@prefix mySiteModel: <dch:org/demo/site/Usage_Eg3_Hobart_Brewery#> .
mySiteModel:siteName a brick:Site .@prefix brick: <https://brickschema.org/schema/Brick#> .
@prefix myBuildingModel: <dch:org/demo/site/Usage_Eg3_Hobart_Brewery/building/visitor_centre_eg3#> .
myBuildingModel:buildingName a brick:Building .Outputs
Zipping up the Manifest, the input_csvs folder and the input_ttls folder and running the tool will produce the following two output files:
@prefix brick: <https://brickschema.org/schema/Brick#> .
@prefix mySiteModel: <dch:org/demo/site/Usage_Eg3_Hobart_Brewery#> .
mySiteModel:siteName a brick:Site ;
brick:keyValue [ brick:key "mgtool" ;
brick:value "build date: 2024-04-08" ],
[ brick:key "mgtool" ;
brick:value "version: 2.0" ] .@prefix brick: <https://brickschema.org/schema/Brick#> .
@prefix myBuildingModel: <dch:org/demo/site/Usage_Eg3_Hobart_Brewery/building/visitor_centre_eg3#> .
myBuildingModel:buildingName a brick:Building ;
brick:keyValue [ brick:key "mgtool" ;
brick:value "build date: 2024-04-08" ],
[ brick:key "mgtool" ;
brick:value "version: 2.0" ] .Example 4: Both manifest and input turtle files, with different mappings
This is ambiguous and should not be done. This example results in undesired and incorrect behaviour given ambiguous definitions for different ID mappins.
Running the above example again but this time with the id_mapping included in the manifest.json file (as per Example 2). I.e in this example/case the URIs for the model_id's are different in the manifest to those in the input turtle file(s). You get the following undesired set of four output files, and the tool will not have correctly merged the supplied input turtle files with the information provided in the input csvs (contents not provided):
mySiteModel.ttl
mySiteModel_1.ttl
myBuildingModel.ttl
myBuildingModel_1.ttl
Importantly the following warnings will be issued in the Log file to indicate the ambiguity, so you can identify when you have accidentally done this:
WARNING | Graph () has a uri clash for prefix myBuildingModel (dch:org/client1/site/Hobart_Waterfront_Hotel/building/Resturant# and dch:org/client2/site/Hobart_Brewery/building/Visitor_Centre#. Check supplied TTL files and manifest for consistency. Setting dch:org/client2/site/Hobart_Brewery/building/Visitor_Centre# to use prefix myBuildingModel_1.
WARNING | Graph () has a uri clash for prefix mySiteModel (dch:org/client1/site/Hobart_Waterfront_Hotel# and dch:org/client2/site/Hobart_Brewery#. Check supplied TTL files and manifest for consistency. Setting dch:org/client2/site/Hobart_Brewery# to use prefix mySiteModel_1.
For information regarding using the model generation tooling to update an existing model, see below:
Advanced: Extending an additional modelLast updated