-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stereotype and filter mapping projects (#826)
- Loading branch information
1 parent
88ccfb4
commit 16ee9a3
Showing
4 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
###Text | ||
Text showcase::model::README | ||
{ | ||
type: markdown; | ||
content: '---\ntitle: Leverage profiles in your model > Stereotypes\ndescription: This an example that shows how to use stereotypes in your data model\n---\n\nThis showcase show how stereotypes can be used in the data model. Stereotypes can be defined at both class level and property level. Stereotypes are used to add additional metadata to your models.\nYou can choose from the various types of stereotypes based on your use case. In this example, \'doc\' stereotype is used to mark the class as deprecated. In addition, the \'integerType\' stereotype is used on the \'age\' field to specify that it expects an Interger and not Long. \nFor more details, refer https://enghub.gs.com/alloy-platform/alloy-studio/docs/tutorials/create-foundational-data-model-elements#stereotypes. \n\nFor more custom use cases, you can create your own profile with custom stereotypes. Here we have create the Profile `showcase::model::CustomProfile` with a stereotype of `custom`.\nWe use this custom profile in the `introduction` derived property of Animal. '; | ||
} | ||
|
||
|
||
###Pure | ||
Profile showcase::model::CustomProfile | ||
{ | ||
stereotypes: [custom]; | ||
} | ||
|
||
Class <<meta::pure::profiles::doc.deprecated>> showcase::model::Animal | ||
{ | ||
name: String[1]; | ||
sound: String[1]; | ||
<<meta::external::language::java::metamodel::profiles::integerType.Integer>> age: Integer[1]; | ||
<<showcase::model::CustomProfile.custom>> introduction() {'Hi my name is ' + $this.name}: String[1]; | ||
} |
12 changes: 8 additions & 4 deletions
12
showcases/data/Model/Leverage profiles in your model/Stereotypes/info.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
--- | ||
title: Stereotypes | ||
description: | ||
development: true | ||
title: Leverage profiles in your model > Stereotypes | ||
description: This an example that shows how to use stereotypes in your data model | ||
--- | ||
|
||
TODO: Some dummy description | ||
This showcase show how stereotypes can be used in the data model. Stereotypes can be defined at both class level and property level. Stereotypes are used to add additional metadata to your models. | ||
You can choose from the various types of stereotypes based on your use case. In this example, 'doc' stereotype is used to mark the class as deprecated. In addition, the 'integerType' stereotype is used on the 'age' field to specify that it expects an Interger and not Long. | ||
For more details, refer https://legend.finos.org/docs/tutorials/studio-profile#stereotype. | ||
|
||
For more custom use cases, you can create your own profile with custom stereotypes. Here we have create the Profile `showcase::model::CustomProfile` with a stereotype of `custom`. | ||
We use this custom profile in the `introduction` derived property of Animal. |
124 changes: 124 additions & 0 deletions
124
showcases/data/Store/Relational Store/Mapping/Joins/Filter Mapping/code.pure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
###Relational | ||
Database showcase::stores::SimpleDB | ||
( | ||
Schema SimpleDBSchema | ||
( | ||
Table Pets | ||
( | ||
id INTEGER PRIMARY KEY, | ||
pet_type VARCHAR(50), | ||
pet_name VARCHAR(50) | ||
) | ||
Table People | ||
( | ||
id INTEGER PRIMARY KEY, | ||
person_name VARCHAR(200), | ||
pet_id INTEGER | ||
) | ||
) | ||
|
||
Join PersonPet(SimpleDBSchema.Pets.id = SimpleDBSchema.People.pet_id) | ||
|
||
Filter petDogFilter(SimpleDBSchema.Pets.pet_type = 'Dog') | ||
) | ||
|
||
|
||
###Text | ||
Text showcase::README | ||
{ | ||
type: markdown; | ||
content: '---\ntitle: Relational Mapping with Join and Filter showcase\ndescription: Showcase displaying a relational mapping with a join and a filter\n---\n\nIn this showcase, two tables (Pets and People) are joined and a filter condition is applied. A test case explaining the use case is added.\n\n'; | ||
} | ||
|
||
|
||
###Pure | ||
Class showcase::models::Pet | ||
{ | ||
pet_name: String[0..1]; | ||
pet_type: String[0..1]; | ||
person_name: String[0..1]; | ||
} | ||
|
||
Class showcase::models::Person | ||
{ | ||
person_name: String[0..1]; | ||
} | ||
|
||
|
||
###Mapping | ||
Mapping showcase::mapping::PetMapping | ||
( | ||
showcase::models::Pet: Relational | ||
{ | ||
~filter [showcase::stores::SimpleDB]petDogFilter | ||
~primaryKey | ||
( | ||
[showcase::stores::SimpleDB]SimpleDBSchema.Pets.id | ||
) | ||
~mainTable [showcase::stores::SimpleDB]SimpleDBSchema.Pets | ||
pet_name: [showcase::stores::SimpleDB]SimpleDBSchema.Pets.pet_name, | ||
pet_type: [showcase::stores::SimpleDB]SimpleDBSchema.Pets.pet_type, | ||
person_name: [showcase::stores::SimpleDB]@PersonPet | [showcase::stores::SimpleDB]SimpleDBSchema.People.person_name | ||
} | ||
|
||
testSuites: | ||
[ | ||
testSuite1: | ||
{ | ||
function: |showcase::models::Pet.all()->filter( | ||
x|$x.pet_type == 'Dog' | ||
)->graphFetch( | ||
#{ | ||
showcase::models::Pet{ | ||
person_name, | ||
pet_name, | ||
pet_type | ||
} | ||
}# | ||
)->serialize( | ||
#{ | ||
showcase::models::Pet{ | ||
person_name, | ||
pet_name, | ||
pet_type | ||
} | ||
}# | ||
); | ||
tests: | ||
[ | ||
test1: | ||
{ | ||
data: | ||
[ | ||
showcase::stores::SimpleDB: | ||
Relational | ||
#{ | ||
SimpleDBSchema.Pets: | ||
'id,pet_name,pet_type\n'+ | ||
'1,Coco,Dog\n'+ | ||
'2,Jojo,Cat\n'; | ||
|
||
SimpleDBSchema.People: | ||
'id,person_name,pet_id\n'+ | ||
'1,Tom,1\n'+ | ||
'2,Jim,2\n'; | ||
}# | ||
]; | ||
asserts: | ||
[ | ||
expectedAssertion: | ||
EqualToJson | ||
#{ | ||
expected: | ||
ExternalFormat | ||
#{ | ||
contentType: 'application/json'; | ||
data: '{\n "person_name": "Tom",\n "pet_name": "Coco",\n "pet_type": "Dog"\n}'; | ||
}#; | ||
}# | ||
]; | ||
} | ||
]; | ||
} | ||
] | ||
) |
7 changes: 7 additions & 0 deletions
7
showcases/data/Store/Relational Store/Mapping/Joins/Filter Mapping/info.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: Relational Mapping with Join and Filter showcase | ||
description: Showcase displaying a relational mapping with a join and a filter | ||
--- | ||
|
||
In this showcase, two tables (Pets and People) are joined and a filter condition is applied. A test case explaining the use case is added. | ||
|