Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples for Logical models #28

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions Examples/Logicals/logical-example.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// @Name: Logical Example
// @Description: An example of Logical resources and how to use them

// A 'Logical' is neither a resource nor a datatype. It can be thought of
// as a data class.
Logical: AnimalAbilities
* hasLungs 0..1 boolean "Does the animal have lungs?"
* canSwim 0..1 boolean "Can the animal swim?"

// A Logical can be used in place of a "complex datatype"
Logical: Animal
* name 1..1 string "The animal's name"
* age 0..1 decimal "The animal's age in years"
* traits 1..1 AnimalAbilities "The animal's abilities"

// A Logical can be a Parent (inheritance)
Logical: Pet
Parent: Animal
* isVaccinated 0..1 boolean "Is the pet vaccinated?"

// A Logical can be like a Resource, but you have to add an id element and the
// #can-be-target Characteristic, so that References work.
Logical: PetAsResourceLikeObject
Parent: Animal
Characteristics: #can-be-target
* id 0..1 string "The id"
* isVaccinated 0..1 boolean "Is the pet vaccinated?"

// Example of Reference from one Logical to another
Logical: Aquarium
* members 0..* Reference(PetAsResourceLikeObject) "The pets inside the aquarium"

// Instance examples:
Instance: ExamplePetPhil
InstanceOf: PetAsResourceLikeObject
* name = "Phil"
* age = 2
* traits.canSwim = true

Instance: ExamplePetClaire
InstanceOf: PetAsResourceLikeObject
* name = "Claire"
* age = 3
* traits.canSwim = false

Instance: ExampleAquarium
InstanceOf: Aquarium
* members[0] = Reference(ExamplePetPhil)
* members[1] = Reference(ExamplePetClaire)
Loading