-
Notifications
You must be signed in to change notification settings - Fork 95
Models Cross Referencing
This page discusses the model cross-referencing system added in PR #362. This system replaces the old system which lived entirely in the NetLogo project.
"Cross-Referencing" is displaying a single library model in two different locations in the models library hierarchy. For instance, the AIDS model is a Biology model, so it should appear under "Sample Models > Biology" but it can also be considered a social science model, so it should also appear under "Sample Models > Social Science". Of course, it's cumbersome to try to keep two copies of the model intact, so we maintain a single model and tell NetLogo to show the model in two different places. We do this through the crossReference.conf
file.
crossReference.conf
lives in the models project root. It is a file written in HOCON, a configuration file-format similar to JSON with more flexible syntax. NetLogo reads crossReference.conf
to determine how models should be duplicated within the models library hierarchy. The general structure of this file consists of two keys: org.nlogo.models.crossReference.singleModels
and org.nlogo.models.crossReference.directories
. Both define a list of objects which specify (respectively) single files and directories. Under no circumstances should these keys be changed without corresponding changes in the NetLogo repository.
To add a single model cross-reference, add a new line in the list defined under the key org.nlogo.models.crossReference.singleModels
containing an object (objects start with {
, end with }
and have key/value pairs). Assuming I have a model at "Sample Models/Foo/Bar.nlogo" and want to reference it as though it were also located at "Code Examples/Bar.nlogo", I would add an entry that looks like the following:
{ source: "Sample Models/Foo/Bar.nlogo", referenceIn: "Code Examples" }
There are a few things to note here:
- I provide the full path to the model relative to the mdoels library root (including .nlogo/.nlogo3d file extension) under the key
source
. - I provide the path to the directory which will contain the reference under the key
referenceIn
. Note that I do not provide a file name. Cross-references will always have the same name as their source. - While the directory given by
referenceIn
does exist within the models library in this example, it is not a requirement that this directory exist. If the directory does not exist, the models library will pretend as though it existed for purposes of displaying to the user. - This object has a line all to itself.
To add a directory cross-reference, add a new line in the list defined under the key org.nlogo.models.crossReference.directories
containing an object (objects start with {
, end with }
and have key/value pairs). Assuming I have a directory at "Sample Models/Mathematics/Foo" and want to reference all models in it as though it were also located at "Curricular Models/Math", I would add an entry that looks like the following:
{ sourceDir: "Sample Models/Mathematics/Foo", referenceIn: "Curricular Models/Math", recursive: false }
A few things to note:
- The path referenced by
sourceDir
must exist (relative to the root of the models project) and must be a directory. - I use
referenceIn
to provide the new path under which all models contained insourceDir
will be referenced. In this example, ifMathematics/Foo
contained a modelA.nlogo
, I would see an entry in the models library for "Curricular Models > Math > A". - Just as with single models, there is no requirement that the directory referenced by
referenceIn
exists within the models library. - The key
recursive
must be present.recursive: false
means that only the immediate children will be referenced (subdirectories will not be).recursive: true
means that both immediate children and subdirectories will be referenced. Note that whenrecursive: true
will create new directories within the reference directory for each subdirectory in the source directory. For instance, if there was a directory "Sample Models/Mathematics/Foo/Bar" and we hadrecursive: true
, the models library would list entries in that directory under "Curricular Models > Math > Foo > Bar". - Directory cross-referencing does not support any kind of filtering or selective referencing (aside from the
recursive
option discussed under 4). If some models should be referenced but others should not be, use single-model cross-references.
The cross-references are tested in CrossReferencesTests.scala
. This only verifies that the source
and sourceDir
keys exist and are files. The referenceIn
keys are not verified, since they may correspond to paths which don't have directories in the models library.
Models Library Editing
- Changes Since Previous Release
- Reviewing a Model for the Library
- Template Letter for Requesting a Review of a Model
- Automated Tests
- Resaving Models in the Newest Release
- Copyright and Citation Info
- Models Cross Referencing
- Models Library Statistics
- What is a Code Example?
- What is a Curricular Model?